NFe_Customizing_SEFAZ.pdf

download NFe_Customizing_SEFAZ.pdf

of 22

Transcript of NFe_Customizing_SEFAZ.pdf

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 1 of 22

    NF-e of SEFAZ Phase 2

    System Configuration

    Note 1018098

    Table of Content:

    1 Introduction ............................................................................................................ 3

    2 Document History .................................................................................................. 3

    3 Overview ................................................................................................................ 4

    3.1 New IMG Activities ....................................................................................... 4

    3.1.1 Assign XML Version to Region .............................................................. 4

    3.1.2 Define SEFAZ Status Codes ................................................................... 4

    3.1.3 Maintain Number Ranges for NF-e ....................................................... 4

    3.1.4 Define NF Type Redetermination for Goods Movements ...................... 4

    3.1.5 Assign RFC Dest. for Outbound Msg to Co. Code and Bus. Place ....... 4

    3.1.6 BAdI: General Enhancements for NF-e ................................................. 5

    3.1.7 Define NF Type Redetermination per Business Place ........................... 5

    3.1.8 Define NF Type Redetermination per State ........................................... 5

    3.1.9 BAdI: Redetermination of Nota Fiscal Type per Line Item ................... 5

    3.2 Enhanced IMG Activities .............................................................................. 5

    3.2.1 Define Nota Fiscal Types ....................................................................... 5

    3.2.2 Adopt screen control for NF types used for NFe ................................... 6

    3.2.3 Assign Numbering and Printing Parameters ......................................... 6

    3.2.4 Define IPI Tax Laws .............................................................................. 6

    3.3 New Business Add-In CL_NFE_PRINT ....................................................... 6

    3.3.1 BAdI Method: RESET_SUBRC .............................................................. 7

    3.3.2 BAdI Method: CHECK_SUBSEQUENT_DOCUMENTS...................... 7

    3.3.3 BAdI Method: FILL_HEADER .............................................................. 7

    3.3.4 BAdI Method: FILL_ITEM .................................................................... 7

    3.3.5 BAdI Method: CALL_RSNAST00 .......................................................... 7

    3.4 New Business Add In CL_SD_NFTYPE ...................................................... 8

    3.4.1 BAdI Method: MODIFY ......................................................................... 8

    4 Required Configurations ........................................................................................ 9

    4.1 Creation of NF types for NF-e ....................................................................... 9

    4.2 Maintain Number Ranges for external NF-e number .................................... 9

    4.3 Authorization: User Actions in NF-e Monitor ............................................... 9

    4.4 Version of XML Layout ................................................................................ 9

    4.5 Contingency settings .................................................................................... 10

    4.5.1 Determination of number range in SD and MM .................................. 10

    4.5.2 Determination of the contingency printer in MM ................................ 10

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 2 of 22

    4.5.3 Determination of the contingency printer in SD .................................. 11

    4.6 SD: NF-Type Determination ........................................................................ 11

    4.7 MM: NF-Type Redetermination for Goods Movements ............................. 12

    4.8 Define Objects for Application Log ............................................................ 12

    4.9 CBT: Mapping of SubTrib Base Reduction ................................................. 12

    4.9.1 Create new conditions for MM & SD .................................................. 12

    4.9.2 Maintain calculation procedure TAXBRA ........................................... 12

    4.9.3 Create new internal codes ................................................................... 12

    4.9.4 Assign internal codes to conditions ..................................................... 12

    4.10 Maintain Alternate County Key ................................................................... 13

    5 Optional Configurations ....................................................................................... 14

    5.1 RFC Destination ........................................................................................... 14

    5.2 Maintenance of SEFAZ Status Codes .......................................................... 14

    5.3 Automated Printing of DANFE ................................................................... 14

    5.4 Transition Phase ........................................................................................... 14

    5.5 IPI Tax Situation for outgoing NFs ............................................................. 15

    5.6 Authorization: Access to NF-e Monitor ...................................................... 15

    6 Communication with Messaging System............................................................. 16

    6.1 Interface for Outbound Messages ................................................................ 16

    6.2 Interfaces for Inbound Messages ................................................................. 17

    6.3 Message Type of Inbound Message ............................................................. 17

    6.4 Backend Control .......................................................................................... 17

    6.5 Messaging-System Control .......................................................................... 17

    7 Appendix .............................................................................................................. 19

    7.1 Example Coding for BAdI Method CALL_RSNAST00 ............................. 19

    7.2 Routine 901 .................................................................................................. 19

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 3 of 22

    1 Introduction The delivery of the functionality for electronic Notas Fiscas (NF-e) is described in

    the overview note 989115.

    The solution for SEFAZ NF-e comprises two parts: (a) an integration of NF-e process logic into the application logic of the SAP backend and (b) a solution for a

    messaging system supporting the implementation in the backend.

    This configuration guide describes the mandatory and optional system configurations

    relevant for NF-e of SEFAZ in the backend. It also gives the information relevant for a solution on the messaging-system side in order to complement and properly

    interact with the SAP backend.

    2 Document History

    History

    Version Date Comment (Author)

    1.0 2007-02-22 Delivered with development phase 2 note 980213

    1.1 2008-02-05 4.3 Authorization: User Actions in NF-e Monitor Authorization for delete NFe changed from 85 to 35

    5.4. Transition Phase

    Delivery note for report J_1BNFEXMLOUTPARALLEL changed from 1017488 to 980213

    Print DANFE Contact added

    1.2 2008-02-07 Chapter 3.2.2 Adopt screen control for NF types used for NFe added

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 4 of 22

    3 Overview This section gives an overview of all new and enhanced IMG activities and BAdIs.

    The purpose and use of these configuration objects is described in the subsequent

    sections Required Configurations and Optional Configurations.

    3.1 New IMG Activities

    3.1.1 Assign XML Version to Region

    IMG:

    Cross-Application Components General Application Functions Nota fiscal Electronic Notas Fiscas (NF-e) Assign XML Version to Region

    VIEW:

    J_1BNFE_XMLV_V

    3.1.2 Define SEFAZ Status Codes IMG:

    Cross-Application Components General Application Functions Nota fiscal Electronic Notas Fiscas (NF-e) Define SEFAZ Status Codes

    VIEW:

    J_1BSTSCODEV

    3.1.3 Maintain Number Ranges for NF-e IMG:

    Cross-Application Components General Application Functions Nota fiscal Electronic Notas Fiscas (NF-e) Maintain Number Ranges for NF-e

    TRANSACTION:

    J1BI_NFE

    3.1.4 Define NF Type Redetermination for Goods Movements

    IMG: Cross-Application Components General Application Functions Nota fiscal Electronic Notas Fiscas (NF-e) Define NF Type Redetermination for Goods Movements

    VIEW:

    J_1BNFTYPEREDMMV

    3.1.5 Assign RFC Dest. for Outbound Msg to Co. Code and Bus. Place

    IMG: Cross-Application Components General Application Functions Nota fiscal Electronic Notas Fiscas (NF-e) Assign RFC Dest. for Outbound Messages to Co. Code and Bus. Place

    VIEW:

    J_1BNFE_RFCD_V

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 5 of 22

    3.1.6 BAdI: General Enhancements for NF-e

    IMG: Cross-Application Components General Application Functions Nota fiscal Electronic Notas Fiscas (NF-e) Business Add-Ins BAdI: General Enhancements for NF-e

    BAdI Definition:

    CL_NFE_PRINT ( transaction SE18)

    3.1.7 Define NF Type Redetermination per Business Place IMG:

    Cross-Application Components General Application Functions Nota fiscal Sales and Distribution - Billing Documents Define Redetermination of Nota Fiscal Type per Business Place

    VIEW:

    J_1B_NFTYPEBRCHV

    3.1.8 Define NF Type Redetermination per State IMG:

    Cross-Application Components General Application Functions Nota fiscal Sales and Distribution - Billing Documents Define Redetermination of Nota Fiscal Type per State

    VIEW:

    J_1B_NFTYPEREGV

    3.1.9 BAdI: Redetermination of Nota Fiscal Type per Line Item IMG:

    Cross-Application Components General Application Functions Nota fiscal Sales and Distribution - Billing Documents BAdI: Redetermination of Nota Fiscal Type per Line Item

    BAdI Definition:

    CL_SD_NFTYPE ( transaction SE18)

    3.2 Enhanced IMG Activities

    3.2.1 Define Nota Fiscal Types IMG:

    Cross-Application Components General Application Functions Nota fiscal Define Nota Fiscal Types

    Enhancements:

    1) New flag Electronic NF Characterizes the NF type as an NF type for electronic Notas Fiscas

    2) New field NF Contin. Type NF type that is used if in case of a contingency switch the contingency NF is not supposed to be an electronic NF

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 6 of 22

    3.2.2 Adopt screen control for NF types used for NFe

    When for NFe a different screen control is required as for normal NF a new screen control group must be defined for the process/transaction.

    Example: for incoming NFe created manually a different field control is required. For

    Normal NF the used screen control group for this process is 5.

    Start transaction SM30.

    View J_1BAMV

    Ignore the warning about changes for SAP data.

    Copy existing screen control group (5) to a new one using next free number (12).

    Go into DETAIL screen and adopt the field control as needed.

    View: J_1BALV

    Assign the new field control group to the NF type used for NFe.

    3.2.3 Assign Numbering and Printing Parameters IMG:

    Cross-Application Components General Application Functions Nota fiscal Output Assign Numbering and Printing Parameters

    VIEW:

    J_1BB2V

    Enhancements:

    1) New NF-e sub-area with: 2) New field for the number-range number of the 9-digit NF-e number (number-range

    object J_1BNFENUM)

    3) New field to specify the NF-e output device that is to be used in contingency when the contingency NF should be an NF-e printed on security paper.

    4) New Flag Numbering Contin. indicating that the contingency NF should be an NF-e printed on security paper.

    5) Re-organization of the screen into three areas containing NF-e specific fields, fields relevant only for non-electronic NFs, and fields relevant for both electronic and non-

    electronic NFs.

    3.2.4 Define IPI Tax Laws IMG:

    Financial Accounting Financial Accounting Global Settings Tax on Sales/Purchases Basic Settings Brazil Define IPI Tax Laws

    VIEW:

    J_1BB2V

    Enhancements:

    New field Tax Sit. IPI Ou in the view for details.

    3.3 New Business Add-In CL_NFE_PRINT

    See IMG Activity: BAdI: General Enhancements for NF-e

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 7 of 22

    3.3.1 BAdI Method: RESET_SUBRC

    Use: Printing of the DANFE without authorization code

    Importing: IS_NFDOC (NF Document Header)

    Exporting: CH_SUBRC

    Based on the data of the NF document header, logic can be implemented to decide if

    the DANFE should be printed without authorization code. If this is the case the

    exported parameter CH_SUBRC must be set to 0.

    3.3.2 BAdI Method: CHECK_SUBSEQUENT_DOCUMENTS

    Use: Block the sending of a request to cancel/skip and NF-e

    Importing: IS_ACTIVE (Current NF-e status entry in table J_1BNFE_ACTIVE) Exporting: CH_SUBRC

    Based on the data of the current NF-e status, logic can be implemented to check if a

    request for authorization to cancel or skip an NF-e should be blocked. If this is the

    case, the output parameter CH_SUBRC must be set to 1.

    3.3.3 BAdI Method: FILL_HEADER

    Use: Fill NF-e header data used in the XML outbound message

    Importing: IN_DOC (NF-e Header)

    Exporting: OUT_HEADER

    OUT_COBRANCA

    This method allows:

    1) To determine XML-header date that is not determined by the SAP backend logic.

    2) To determine cobranca data, which is not determined by the SAP backend logic.

    3) To overwrite the XML version determined by the SAP backend system.

    3.3.4 BAdI Method: FILL_ITEM

    Use: Fill NF-e item data used in the XML outbound message

    Importing: IN_DOC (NF-e Header)

    IN_LIN (NF-e Item data)

    IN_TAX (NF-e Tax data)

    Exporting: OUT_ITEM

    OUT_BATCH

    This method allows:

    1) To determine item data that is not determined by the SAP backend logic. The possible fields are defined in structure J1B_NF_XML_BADI_ITEM.

    2) To fill batch data (for medicines) in a table defined in table type J1B_NF_XML_J_TAB.

    3.3.5 BAdI Method: CALL_RSNAST00

    Use: Fill NF-e item data used in the XML outbound message

    Importing: I_ACTIVE (NF-e Current Status)

    This method allows:

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 8 of 22

    1) To implement coding that triggers and automatic printing of a DANFE upon receipt of the authorization from SEFAZ.

    3.4 New Business Add In CL_SD_NFTYPE

    See IMG Activity: BAdI: Redetermination of Nota Fiscal Type per Line Item

    3.4.1 BAdI Method: MODIFY

    Use: Overwrite the NF type that was determined automatically by the system.

    Importing: IV_BUKRS (Company Code)

    IV_BRANCH (Business Place)

    IV_COUNTRY (Country Key)

    IV_REGIO (Region (State, Province, County))

    IV_AUART (Sales Document Type)

    IV_CONTING (Contingency identifier for NF-e)

    IS_VBAK (Sales Document: Header Data)

    IS_VBAP (Sales Document: Item Data)

    IS_VBKD (Sales Document: Business Data)

    IS_LIKP (SD Document: Delivery Header Data)

    IS_LIPS (SD document: Delivery: Item data)

    Changing: CV_NFTYPE (Nota Fiscal Type)

    Exception: ERROR (An error has occurred)

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 9 of 22

    4 Required Configurations This section gives a description of all mandatory system configurations. You will find

    a subsection per configuration topic.

    4.1 Creation of NF types for NF-e

    The system recognizes an NF-e process based on the assigned NF type. For NF-e

    processes, new NF types must be defined (IMG activity Define Nota Fiscal Types).

    Copy existing ones and set in the new ones the NF-e flag.

    4.2 Maintain Number Ranges for external NF-e number

    New number ranges for the external NF-e number you define per number-range group

    in the IMG activity Maintain Number Ranges for NF-e.

    4.3 Authorization: User Actions in NF-e Monitor

    User actions in the NF-e Monitor (transaction J1BNFE) are subject to authorization

    checks. The authorization object F_NFBA involved is available with note 687829.

    User Action Auth. Object Activity

    Request an authorization to cancel an authorized NF-e F_NFBA 85 [reverse])

    Request an authorization to cancel a rejected NF-e F_NFBA 85 [output])

    Set Contingency per Region or per Business Place F_NFBA 85 [reverse])

    Delete NF-e log entries F_NFBA 35 [output])

    Send NF-e with SCS ' ' (not sent) F_NFBA 35 [output])

    Set Contingency per NF-e F_NFBA 35 [output])

    Reset Contingency per NF-e F_NFBA 35 [output])

    Check XI connection no check

    Check NF-e log no check

    Display NF-e in NF writer no check

    4.4 Version of XML Layout

    Maintain the current version of the XML layout in the IMG activity Assign XML

    Version to Region. The current version of the XML layout is defined per state.

    The XML layout you maintain in the IMG activity Assign XML Version to Region is

    passed via the outbound interface to the messaging system. Based on the layout, the

    messaging system maps the NF-e data to the XML message structure.

    The XML version does not impact the backend logic. You must ensure that the

    version you maintain is supported by the backend. Implement the relevant notes or

    upgrade to the required support package. The delivery of the XML versions is

    described in the overview note 989115.

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 10 of 22

    If you need different XML versions within one state, you must implement the method

    BAdI Method: FILL_HEADER of the Business Add-In CL_NFE_PRINT to overwrite

    the version you have maintained in the IMG activity Assign XML Version to Region.

    This might be the case if different business places of your company located in the

    same region communicate with different SEFAZ systems (for production and for

    testing) that require different versions.

    4.5 Contingency settings

    This section considers NF-es that have been posted under normal process conditions

    and are switched to contingency.

    Whenever you decide to continue a business process in contingency, i.e., to print the

    related, already created invoice without prior authorization by the government you

    must decide if you want to print the invoice as an electronic NF or as a non-electronic

    NF. Electronic contingency NFs are to be printed on security paper using a laser

    printer. In this case, the NF model, e.g., 55 and the NF-e number range remain

    unchanged. Non-electronic NFs are printed on dot-matrix printers. NF model and NF

    number range change. In any case, the initial NF must be cancelled together with the

    source document from SD, MM, or IV and a new NF must be posted.

    4.5.1 Determination of number range in SD and MM

    Case 1: Printing on security paper as NF-e

    To keep the model and the number range, set the indicator Numbering Contin. in the

    sub-area NF-e for the relevant entry in the IMG activity Assign Numbering and

    Printing Parameters.

    Case 2: Printing as classical NF

    Do not set the indicator Numbering Contin. in the sub-area NF-e for the relevant entry

    in the IMG activity Assign Numbering and Printing Parameters. Instead, assign a

    contingency NF type to the electronic NF type in the field NF Contin. Type in the

    IMG activity Define Nota Fiscal Types. The contingency NF type must not have the

    indicator Electronic NF set. You may use an already existing non-electronic NF type.

    The NF number range for the non-electronic contingency NF type is defined in the

    relevant entry of the IMG activity Assign Numbering and Printing Parameters in the

    field No. range no. of the sub-area Normal NF.

    4.5.2 Determination of the contingency printer in MM

    Case 1: Printing on security paper as NF-e

    Maintain the contingency printer, which in this case must be a laser printer in the IMG

    activity Assign Numbering and Printing Parameters in the field Output Device of the

    sub-area NF-e.

    Case 2: Printing as classical NF

    Do not maintain a printer as described in case 1. Instead, assign a contingency NF

    type to the electronic NF type in the field NF Contin. Type in the IMG activity Define

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 11 of 22

    Nota Fiscal Types. The determination of the dot-matrix printer is then done based on

    the configurations related to the non-electronic contingency NF type.

    4.5.3 Determination of the contingency printer in SD

    Case 1: Printing on security paper as NF-e

    You can maintain the contingency printer, which in this case must be a laser printer in

    the field Output Device of the sub-area NF-e of the IMG activity Assign Numbering

    and Printing Parameters.

    Alternatively, you can configure the contingency printer using the classical printer

    configuration.

    Case 2: Printing as classical NF

    Do not maintain a printer as described in case 1. Instead, assign a contingency NF

    type to the NF type of the initial NF-e. You can specify the contingency NF type in

    the field NF Contin. Type in the IMG activity Define Nota Fiscal Types. The

    contingency NF type must not have the indicator Electronic NF set.

    4.6 SD: NF-Type Determination

    Two new maintenance views are available to enhance the classic Nota Fiscal Type

    determination based on the sales order type.

    The determination checks first if a NF type is assigned to the sales-order type (classic determination).

    If there is one, the system checks if this classic NF type has to be replaced by a Nota Fiscal type defined per business place (view J_1B_NFTYPEBRCHV).

    If no NF type is maintained per business place, the system checks if the classic NF type has to be replaced by a NF type defined per state (view J_1B_NFTYPEREGV).

    Eventually, the system checks for an implementation of the BAdI method MODIFY of the BAdI CL_SD_NFTYPE. With this BAdI method it is possible to

    assign a NF type at line-item level during the billing process. Consequence: The

    system induces a billing document split to ensure that only line items having the same

    NF type are included in a billing document. To support this feature the user must

    maintain the billing document data transport routine 901 (coding in the appendix) for

    the relevant entries in the following IMG activities:

    IMG: Sales and Distribution Billing Billing Documents Maintain Copying Control for billing documents Copying control: Sales document to billing document

    IMG: Sales and Distribution Billing Billing Documents Maintain Copying Control for billing documents Copying control: Delivery document to billing document

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 12 of 22

    4.7 MM: NF-Type Redetermination for Goods Movements

    In case of goods movements, the NF type is determined from the movement type. The

    existing assignment of NF types to movement type in the IMG activity Materials

    Management Inventory Management and Physical Inventory Nota Fiscal Maintain Nota Fiscal Category Derivation remains unchanged.

    Assign NF-e types to MM movement types per plant in the IMG activity Define NF

    Type Redetermination for Goods Movements. A duplication of movement types for

    NF-e processes is not necessary.

    A configuration in the IMG activity Define NF Type Redetermination for Goods

    Movements is thus required for those plant and business transactions (movement

    types) that are subject to NF-e processing.

    4.8 Define Objects for Application Log

    Use transaction SLG0.

    Create the object NFE with the object text Nota Fiscal Electronica.

    For the object NFE, create the sub-object MONITOR with the sub-object text

    Monitor.

    4.9 CBT: Mapping of SubTrib Base Reduction

    The configurations described in this section are only relevant if condition-based tax

    calculation used for Brazilian company codes.

    4.9.1 Create new conditions for MM & SD

    Transaction J1BTAX Condition Setup Condition types Copy BX44 to BX45 Short text: BRSubTrib NF Basred1

    Copy BX45 to BX46 Short text: BRSubTrib NF Basred2

    4.9.2 Maintain calculation procedure TAXBRA

    Transaction J1BTAX Condition Setup Calc. procedures Calc. procedure MM

    Insert two new steps after the step with condition BX44 as copy from step with BX44.

    In the first new step insert condition BX45, in the second BX46.

    Repeat the same steps for used SD calculation procedures.

    4.9.3 Create new internal codes Transaction J1BTAX Condition Setup Condition Mapping Internal Codes NF_SUBTRIB_BASERED1 Federal base reduction Rate for Subtrib

    NF_SUBTRIB_BASERED2 State base reduction Rate for Subtrib

    4.9.4 Assign internal codes to conditions Transaction J1BTAX Condition Setup Condition Mapping Assign Conditions to Internal Codes

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 13 of 22

    Internal code Appl. Condition

    NF_SUBTRIB_BASERED1 TX BX45

    NF_SUBTRIB_BASERED1 V BX45

    NF_SUBTRIB_BASERED2 TX BX46

    NF_SUBTRIB_BASERED2 V BX46

    4.10 Maintain Alternate County Key

    With the alternate country key, the IGBE country code is determined and set for the

    XML File.

    IMG: General Settings Set countries Define countries in R/3 Systems

    In the detail view insert:

    Country Alternate country key

    BR 508 Brazil

    CL 512 Chile

    PY 520 Paraguay

    UY 524 Uruguay

    AR 528 Argentina

    In case of using a country code different from those described above, create

    corresponding entries.

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 14 of 22

    5 Optional Configurations This section gives a description of all optional system configurations. You will find a

    subsection per configuration topic.

    5.1 RFC Destination

    The default RFC destination is ENF_BR_2006.

    The RFC destination ENF_BR_2006 is hard-coded. If you want to use a different

    RFC destination, you need to maintain it in the IMG activity Assign RFC Dest. for

    Outbound Messages to Co. Code and Bus. Place.

    The link between the RFC destination (input channel of the messaging system) and

    the respective government system for production or testing needs to be defined in the

    messaging system.

    5.2 Maintenance of SEFAZ Status Codes

    SEFAZ sends a status code with each response message. These codes provide

    information about the reason for a particular response, e.g., the reason for a rejection

    of an authorization request.

    The SEFAZ status code is a mandatory field of the inbound interface from the

    messaging system to the backend. The maintenance of status codes with description is

    possible but not mandatory. Independent of the definition of status codes in the IMG

    activity Define SEFAZ Status Codes the code itself (not the description) is stored in

    the NF-e data base.

    5.3 Automated Printing of DANFE

    When you post a document in Sales and Distribution (SD) or Materials Management

    (MM) that generates an electronic nota fiscal (NF-e), you cannot print the NF-e

    immediately; you must first wait for authorization from SEFAZ. Once SEFAZ

    approves your NF-e and returns a corresponding protocol number, the system does not

    print the NF-e automatically. You must print the NF-e manually using the NF Writer.

    You can use the method CALL_RSNAST00 of the BAdI CL_NFE_PRINT to trigger

    automatic printing of the NF-e upon receipt of authorization from SEFAZ. You can

    find an example coding in the appendix of this document.

    5.4 Transition Phase

    During a transition phase from classical NF posting to NF-e processing, the legally

    relevant notas fiscas are non-electronic, i.e., of model 1/1A. However, the NF data is

    sent to SEFAZ as an XML message as if the posted NF was an NF-e. The model in

    the XML message must be 55. The NF number is the 6-digit non-electronic number. It

    is not required to receive an authorization prior to printing the NF. The DANFE (with

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 15 of 22

    or without protocol number) must be printed and together with the NF of model 1/1A

    be sent with the goods. To enable this process, you need to do the following:

    1) To create an outbound XML message, inset the following entry in the IMG activity

    Nota Fiscal Output Processing Program:

    Medium Short text Program FROM routine

    1 Print output J_1BNFEXMLOUTPARALLEL ENTRY

    2) Enhancement of the report J_1BNFEXMLOUTPARALLEL (optional)

    The report is delivered via support package or implemented with note 980213. You

    may implement checks or logic to fill fields in the XML file directly in the report.

    Recommendation: copy report to z-report and modify the z-report. In this case, insert

    the z-report in the IMG activity processing program.

    3) Maintain an RFC destination for the parallel phase and link it to the test system of

    the government (configuration of the messaging system). See chapter RFC Destination.

    4) Print the DANFE. Up to now a layout for DANFE printing is not available in the

    SAP standard delivery. SAP Brazil developed a local solution which is available with

    note 955155 for pilot customers. For more details please contact

    [email protected]

    or component XX-PROJ-BR-NFE

    5.5 IPI Tax Situation for outgoing NFs

    The XML layout contains separate fields for the IPI tax situation for incoming and

    outgoing NF-es. You can maintain an IPI tax situation for outgoing NF-es that is

    different from the IPI tax situation for incoming NF-es. You do that in the IMG

    activity Define IPI Tax Laws in the field Tax Sit. IPI Ou. If you do not maintain an

    entry in this field, the system will take the entry maintained in the field Tax Sit. IPI In

    for both, incoming and outgoing NF-es.

    5.6 Authorization: Access to NF-e Monitor

    The access to the NF-e Monitor via transaction J1BNFE can be restricted. To this end,

    implement note 687829 and activate the NF authorization checks as described in this

    note. If authorization checks are activated, only users who have the authorization

    object F_NFBA, activity 03 [display] assigned to their authorization profile can

    access the NF-e Monitor via transaction J1BNFE. This is the same authorization as

    required to use the NF-writer display transaction J1B3N.

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 16 of 22

    6 Communication with Messaging System This section gives a description of the backend functionalities that are relevant for the

    communication between backend and messaging system, e.g., the SAP Exchange

    Infrastructure (XI). Corresponding settings and configuration of the messaging system

    is mandatory.

    6.1 Interface for Outbound Messages

    The backend asynchronously sends messages via the outbound interface:

    J_1B_NFE_XML_OUT (Function Module)

    This interface provides the NF-e data as required by the authorities according to the

    currently valid XML layout together with the NF-e document status (DS), the NF-e

    system communication status (SCS), and the contingency flag. The messaging system

    has the task to map the NF-e data to the layout structure of the XML file. The NF-e

    document status and the NF-e system communication status contain the information

    about the type of outbound message, which could be one of the following:

    1) Request for authorization 2) Submission of a Contingency NF-e 3) Request to authorize the cancellation of an authorized NF-e 4) Request to skip the number of a rejected NF-e

    The identification of the different types of outbound messages is given by the value of

    the following interface fields

    XML_IN- DOCSTAT

    XML_IN- SCSSTAT

    XML_IN- CONTING

    as follows

    Message DOCSTAT SCSSTAT CONTING

    (1) Request for authorization initial 0 initial

    (2) Submission of a contingency NF-e initial 0 X

    (3) Request to authorize the cancellation of an authorized NF-e

    1 1 Initial

    (4) Request to skip the number of a rejected NF-e

    2 3 initial

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 17 of 22

    6.2 Interfaces for Inbound Messages

    The back end can receive messages via the inbound interfaces:

    J_1B_NFE_XML_IN (Function Module) single NF-e processing

    J_1B_NFE_XML_IN_TAB (Function Module) batch NF-e processing

    The inbound interfaces can process any of the following message types:

    1) SEFAZ authorization of an NF-e 2) SEFAZ rejection of an NF-e 3) SEFAZ denial of an NF-e 4) SEFAZ authorization to cancel an authorized NF-e 5) SEFAZ authorization to cancel a rejected NF-e 6) SEFAZ rejection of a request for authorization to cancel an authorized NF-e 7) SEFAZ rejection of a request for authorization to cancel a rejected NF-e

    Protocol number, SEFAZ status code, and the message type are mandatory importing

    parameters. In addition, the access key of the NF-e or alternatively the SAP internal

    NF-e document number (if the NF-e was created by the SAP backend, the internal

    document number is in stored in the random-number field of the access key) must be

    passed to the backend.

    6.3 Message Type of Inbound Message

    The backend expects a unique code identifying the type of inbound message. These

    codes are defined in the backend. The supported message types and their respective

    codes are:

    Message code Message type

    1 Authorization of NF-e

    2 Rejection of NF-e

    3 Denial of NF-e

    4 Authorization to Cancel an Authorized NF-e

    5 Authorization to Cancel a Rejected NF-e (Skipping)

    6 Rejection of a Request for Cancellation

    7 Rejection of a Request for Skipping

    6.4 Backend Control

    Important: with the current solution, the backend assumes an NF-e message has

    reached the authorities once it has successfully been sent to the messaging system.

    The messaging system must not change the content of the message. This would lead

    to an inconsistency of data between the backend and SEFAZ. Neither should the

    messaging system switch an NF-e received from the backend to contingency.

    6.5 Messaging-System Control

    The messaging system can activate and deactivate contingency in the backend on

    business-place level.

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 18 of 22

    This is possible via the remote-enabled function module

    J_1B_NFE_CONTINGENCY_SET.

    In the interface, the messaging system must specify the fields LAND1, BUKRS, and

    BRANCH. The field REGIO must remain initial. The messaging system may select or

    deselect the indicator AS_OUT. This indicator is interpreted by the backend. If it is

    set, the backend switches to contingency for any subsequent NF-e posting. The

    indicator can be automatically deactivated through the messaging system or manually

    by a user with the required authorization profile.

    IMPORTANT: If the function module J_1B_NFE_CONTINGENCY_SET is called

    remotely by the messaging system, the importing parameter IV_FIRE_COMMIT

    must be set to X.

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 19 of 22

    7 Appendix

    7.1 Example Coding for BAdI Method CALL_RSNAST00

    This Coding can be used after installation of note 1037070. call function J_1BNFE_CALL_RSNAST00 exporting i_active = i_active i_nfdoc = i_nfdoc exceptions no_printer = 1 others = 2 . if sy-subrc 0. call function 'J_1B_NFE_ERROR_PROTOKOLL' exporting i_docnum = i_active-docnum. endif. The function J_1BNFE_CALL_RSNAST00 is in the standard delivery for NF-e. It provides the following interface: I_ACTIVE must always be filled with from the BADI interface. I_NFDOC can be filled from the BADI interace when the printer should be determined as maintained in the output configuration I_KAPPL for NF-e the default Application NF has to be used I_NACHA for printing the transmission medium must be set to 1 as per Default I_DIMME print immediately is per default set to X, can bes et to space When the output should not be printed immediately I_PRINTER can be used when the output should be send to a different printer as defined in the output determination for NF-e

    When during the BADI process error occurs, the messages are written in the error log

    and can be controlled with the report J_1BNFE_MONITOR.

    7.2 Routine 901

    Create a new Data Transport Routine, e.g., with the routine no. 901 and the

    description NF split by NFtype

    Copy the following source code into the routine and activate the source code.

    * Header data * VBRK-xxxxx = ............

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 20 of 22

    * Item data * VBRP-xxxxx = ............ * Additional split criteria DATA: BEGIN OF ZUK, MODUL(3) VALUE '901', VTWEG LIKE VBAK-VTWEG, SPART LIKE VBAK-SPART,1 VSTEL lIKE VBAP-VSTEL, CONTING type j_1bcontingency, NFTYPE type J_1BNFTYPE, END OF ZUK. DATA: lv_branch type J_1BBRANC_, lv_bukrs type bukrs, lv_werks type werks, lv_werks_d type WERKS_d, lv_branch_address type sadr, lv_conting type j_1bcontingency, lv_vgbel type vgbel, lv_vgpos type vgpos, lv_vstel type vstel. ZUK-SPART = VBAK-SPART. ZUK-VTWEG = VBAK-VTWEG. ZUK-VSTEL = VBAP-VSTEL. * Identify the plant lv_werks = vbap-werks. if not likp-werks is initial. lv_werks = likp-werks. endif. if not lips-werks is initial. lv_werks = lips-werks. endif. if lv_werks is initial. raise ERROR. endif. * Identify the shipping point lv_vstel = likp-vstel. if lv_vstel is initial. lv_vstel = vbap-vstel. endif. * Identify the previous doc and posnr lv_vgbel = LIPS-VBELN. lv_vgpos = LIPS-posnr. if lv_vgbel is initial and lv_vgpos is initial. lv_vgbel = vbap-VBELN. lv_vgpos = vbap-posnr. endif. if lv_vgpos is initial or lv_vgbel is initial. raise ERROR. endif.

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 21 of 22

    CALL FUNCTION 'J_1B_BRANCH_DETERMINE' EXPORTING plant = lv_werks IMPORTING branch = lv_branch EXCEPTIONS branch_not_found = 01 plant_not_found = 02 valuation_area_not_found = 03 company_not_found = 04. IF not sy-subrc is initial. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. lv_werks_d = lv_werks. CALL FUNCTION 'DETERMIN_BWKEY_BUKRS_FOR_PLANT' EXPORTING werk = lv_werks_d IMPORTING bukrs = lv_bukrs. CALL FUNCTION 'J_1BREAD_BRANCH_DATA' EXPORTING branch = lv_branch bukrs = lv_bukrs IMPORTING address = lv_branch_address * BRANCH_DATA = * CGC_NUMBER = * ADDRESS1 = * TABLES * ET_ADR6 = EXCEPTIONS branch_not_found = 1 address_not_found = 2 company_not_found = 3 OTHERS = 4. IF sy-subrc 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. call function 'J_1B_SD_NFTYPE_DET' exporting iv_bukrs = lv_bukrs iv_branch = lv_branch iv_vstel = lv_vstel iv_country = lv_branch_address-land1 iv_regio = lv_branch_address-regio iv_auart = vbak-auart iv_vgbel = lv_vgbel iv_vgpos = lv_vgpos is_vbak = vbak is_vbap = vbap is_lips = lips

  • Configuration Guide for NF-e

    2009 SAP

    Dietmar-Hopp Allee 16

    D-69190 Walldorf

    Version: 1.2

    Date: 02/07/2008

    Page 22 of 22

    is_likp = likp is_vbkd = vbkd importing ev_nftype = ZUK-NFTYPE ev_conting = ZUK-CONTING exceptions error = 1 others = 2. if sy-subrc 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. endif. VBRK-ZUKRI = ZUK.