Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Parameter Name Typing Associated Type Default Optional Pass Short text
Value value
IS_J_1BNFDOC TYPE J_1BNFDOC Nota
Fiscal
Header
IT_J_1BNFE_ACTIVE TYPE J_1BNFE_ACTIVE X Electronic
Nota
Fiscal:
Actual
Status
Go to the tab Source Code tab erase the content there and add the following code:
FUNCTION j_1bsped_get_cod_sit.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IS_J_1BNFDOC) TYPE J_1BNFDOC
*" REFERENCE(IT_J_1BNFE_ACTIVE) TYPE J_1BNFE_ACTIVE OPTIONAL
*" EXPORTING
*" REFERENCE(EV_COD_SIT) TYPE CHAR2
*"----------------------------------------------------------------------
*" Possible document status
*" 0 - Regular Document
*" 1 - Regular Extemporaneous Document
*" 2 - Cancelled Document
*" 3 - Extemporaneous Cancelled Document
*" 4 - NFe Denied
*" 5 - NFe Skipped
*" 6 - Complementary Fiscal Document
*" 7 - Extemporaneous Complementary Fiscal Document
*" 8 - Fiscal Document Based on Special Legal Base or Specific Norm
DATA ls_nfe_active TYPE j_1bnfe_active.
CONSTANTS: lc_complementar TYPE j_1bdoctyp VALUE '2'.
IF NOT is_j_1bnfdoc-cancel IS INITIAL AND is_j_1bnfdoc-model <> '55'.
ev_cod_sit = '02'.
RETURN.
ELSE.
ev_cod_sit = '00'.
ENDIF.
"complementar (independent of model)
IF is_j_1bnfdoc-doctyp = lc_complementar.
ev_cod_sit = '06'.
RETURN.
ENDIF.
" NFe
IF is_j_1bnfdoc-model = '55'. "what about model 57?
"a NFe can be created without being numbered yet.
CHECK NOT is_j_1bnfdoc-nfenum IS INITIAL.
SELECT SINGLE * FROM j_1bnfe_active INTO ls_nfe_active
WHERE docnum = is_j_1bnfdoc-docnum.
IF sy-subrc IS INITIAL.
IF ls_nfe_active-action_requ EQ 'C'. "completed
CASE ls_nfe_active-docsta.
WHEN '1'. "authorized
IF ls_nfe_active-cancel EQ 'X'.
ev_cod_sit = '02'.
ELSE.
ev_cod_sit = '00'.
ENDIF.
WHEN '2'. "rejected
ev_cod_sit = '05'.
WHEN '3'. "denied
ev_cod_sit = '04'.
WHEN OTHERS. "internal validation error
ENDCASE.
ELSE.
ev_cod_sit = ''.
ENDIF.
ELSE.
RETURN. "error?
ENDIF.
ENDIF.
ENDFUNCTION.
Go to the tab Source Code tab erase the content there and add the following code:
FUNCTION j_1bsped_get_cod_cta.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_COMPANY) TYPE BKPF-BUKRS
*" REFERENCE(IS_J_1BNFDOC) TYPE J_1BNFDOC
*" REFERENCE(IS_J_1BNFLIN) TYPE J_1BNFLIN
*" EXPORTING
*" REFERENCE(EV_COD_CTA) TYPE CHAR_60
*"----------------------------------------------------------------------
DATA ls_bkpf TYPE gty_bkpf.
DATA ls_bseg TYPE gty_bseg.
DATA lv_year TYPE j_1bnfdoc-gjahr.
DATA lv_awtyp TYPE bkpf-awtyp.
IF NOT is_j_1bnfdoc-gjahr IS INITIAL.
lv_year = is_j_1bnfdoc-gjahr.
ELSE.
lv_year = is_j_1bnfdoc-pstdat(4).
ENDIF.
PERFORM get_accounting_docs
USING
is_j_1bnfdoc
is_j_1bnflin
iv_company
lv_year
CHANGING
gt_bkpf
gt_bseg
lv_awtyp.
* EFD Logic
SORT gt_bseg BY wrbtr DESCENDING.
*- read table BSEG with BELNR and store records
LOOP AT gt_bkpf INTO ls_bkpf
WHERE bukrs = iv_company
AND gjahr = lv_year
AND awkey = is_j_1bnflin-refkey
AND awtyp = lv_awtyp.
LOOP AT gt_bseg INTO ls_bseg
WHERE belnr = ls_bkpf-belnr
AND bukrs = ls_bkpf-bukrs
AND gjahr = ls_bkpf-gjahr.
IF ls_bseg-kunnr = '' AND
ls_bseg-lifnr = ''.
ev_cod_cta = ls_bseg-hkont.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFUNCTION.
Go to the tab Source Code tab erase the content there and add the following code:
FUNCTION j_1bsped_counter_read.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" REFERENCE(ET_REGISTERS_COUNTER) TYPE
*" J_1BSPED_T_REGISTER_COUNTER
*"----------------------------------------------------------------------
et_registers_counter = gt_registers_counter.
ENDFUNCTION.
Go to the tab Source Code tab erase the content there and add the following code:
FUNCTION j_1bsped_counter_increase.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IV_REGISTER) TYPE C
*"----------------------------------------------------------------------
*
* DATA ls_registers_quantity TYPE gty_registers_quantity.
FIELD-SYMBOLS <ls_registers_quantity>
TYPE j_1bsped_s_register_counter.
* find the register to be incrementeed
READ TABLE gt_registers_counter
WITH KEY register = iv_register
ASSIGNING <ls_registers_quantity>.
* test if there is a line for this register
IF sy-subrc = 0.
* increment the amount of this register in the global table
<ls_registers_quantity>-quantity =
<ls_registers_quantity>-quantity + 1.
ENDIF.
ENDFUNCTION.