Configuration Guide for NF-e
NF-e of SEFAZ – Phase 2 System Configuration Version 2.0
Note 1018098
Table of Content:
1 2 3
Introducti Introduction on ................................. .................................................. .................................. .................................. ................................. ................... ... 3 Document Document History.......... History........................... .................................. ................................. ................................. .................................. ................. 3 Overview.......................... Overview........................................... .................................. ................................. ................................. ............................... .............. 4 3.1 New IMG Activities........................... Activities........................................... ................................. .................................. ....................... ...... 4 Assign XML Version to Region ............................... 3.1.1 ................................................ ............................ ........... 4 3.1.2 ................................................. .............................. .............. 4 Define SEFAZ Status Codes ................................. Maintain Number Ranges for NF-e .................................. 3.1.3 ................................................... ................... .. 4 3.1.4 ............... ......... ...... .. 4 Define NF Type Redetermination for Goods Movements .......... Assign RFC Dest. for Outbound Msg to Co. Code and Bus. Place .... 3.1.5 ...... .. 4 3.1.6 .............................................. .............. 5 BAdI: General Enhancements for NF-e ................................ 3.1.7 .............. .......... ......... ...... .. 5 Define NF Type Redetermination per Business Place ......... Define NF Type Redetermination per State ................................. 3.1.8 ......................................... ........ 5 3.1.9 ............. ......... ..... 5 BAdI: Redetermination of Nota Fiscal Type per Line Item ......... 3.2 Enhance Enhanced d IMG Activities Activities................ ................................. ................................. ................................. .......................... ......... 5 3.2.1 ................................................... ................................. ................ 5 Define Nota Fiscal Types .................................. Assign Numbering and Printing Parameters .................................. 3.2.2 ....................................... ..... 6 3.2.3 .................................................. ................................. ......................... ........ 6 Define IPI Tax Laws .................................. 3.3 New Business Business Add-In Add-In CL_NFE_P CL_NFE_PRINT RINT ................................ ................................................. .................... ... 6 BAdI Method: RESET_SUBRC ............................... 3.3.1 ................................................ ............................ ........... 6 BAdI Method: CHECK_SUBSEQUENT_DOCUMENTS CHECK_SUBSEQUENT_DOCUMENTS ......... 3.3.2 .............. ......... ...... .. 6 BAdI Method: FILL_HEADER ............................... 3.3.3 ................................................ ............................ ........... 7 3.3.4 ................................................. ................................. ................ 7 BAdI Method: FILL_ITEM ................................ BAdI Method: CALL_RSNAST00 ............................... 3.3.5 ................................................ ......................... ........ 7 3.4 New Business Business Add In CL_SD_NFT CL_SD_NFTYPE........ YPE........................ ................................. ............................ ........... 7 BAdI Method: MODIFY ................................. 3.4.1 .................................................. .................................. ................... .. 7 4 Required Required Configurati Configurations ons................. .................................. ................................. ................................. .................................. ................. 9 4.1 Creation Creation of NF types for NF-e........................ NF-e........................................ ................................. ............................ ........... 9 4.2 Maintain Maintain Number Number Ranges Ranges for external external NF-e number number .................................. .................................. 9 4.3 Authoriza Authorization: tion: User Actions Actions in NF-e Monitor Monitor ................................ ............................................ ............ 9 4.4 Version Version of XML Layout........................... Layout........................................... ................................. .................................. ................. 9 4.5 Contingen Contingency cy settings settings ................................ ................................................ ................................. .................................1 ................10 0 Determination of number range in SD and MM .................................10 4.5.1 4.5.2 Determination of the contingency printer in MM ...............................10 © 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 1 of 22
Configuration Guide for NF-e
Determination of the contingency printer in SD .................................11 4.5.3 4.6 SD: NF-Type NF-Type Determina Determination tion ................................. .................................................. .................................. ...................11 ..11 4.7 MM: NF-Type Redetermination Redetermination for Goods Movements Movements ................... .......... .................. .........12 12 4.8 CBT: Mapping of SubTrib Base Reduction .................. ........ ................... ................... ................... ..........12 .12 Create new conditions for MM & SD .................................. 4.8.1 .................................................1 ...............12 2 4.8.2 ..........................................12 ..........12 Maintain calculation procedure TAXBRA ................................ Create new internal codes ................................. 4.8.3 .................................................. ................................1 ...............12 2 4.8.4 ................................................... ..................12 .12 Assign internal codes to conditions .................................. 4.9 Maintain Alternate County Key................... Key......... ................... .................. ................... ................... ..................1 .........13 3 5 Optional Configurations..................... Configurations........... ................... .................. ................... ................... .................. ................... .................14 .......14 5.1 RFC Destination Destination ................................ ................................................. ................................. ................................. ......................14 .....14 5.2 Maintenance of SEFAZ Status Codes..................... Codes............ ................... ................... ................... ................14 ......14 5.3 Automated Automated Printing Printing of DANFE DANFE ................................ ................................................. .................................1 ................14 4 5.4 Transiti Transition on Phase................... Phase................................... ................................. .................................. .................................. ...................14 ..14 5.5 IPI Tax Situation Situation for outgoin outgoing g NFs ................................ ................................................. ...........................15 ..........15 5.6 Authorization: Access to NF-e Monitor................ Monitor....... ................... ................... .................. ..................1 .........15 5 6 Communication Communication with Messaging System................... System.......... ................... ................... ................... ................... ...........16 ..16 6.1 Interface for Outbound Messages Messages ................... ......... ................... .................. ................... ................... ...............16 ......16 6.2 Interfaces for Inbound Messages .................. ......... .................. ................... ................... ................... .................17 .......17 6.3 Message Type of Inbound Message................ Message...... ................... ................... ................... .................. ...............17 ......17 6.4 Backend Backend Control ................................ ................................................. .................................. ................................. .....................17 .....17 6.5 Messaging Messaging-Syste -System m Control ................................. ................................................. ................................. ......................17 .....17 7 Appendi Appendix x ................................ ................................................. ................................. ................................. .................................. ........................19 .......19 7.1 Example Coding for BAdI Method CALL_RSNAST00 CALL_RSNAST00 ................... ......... ................... .........19 19 7.2 Routine Routine 901 .................................. .................................................. ................................. .................................. ...........................19 ..........19
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 2 of 22
Configuration Guide for NF-e
1
Introduction
The delivery of the functionality for electronic Notas Fiscaís (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 2007-09-17
Delivered with development phase 2 – note 980213
2.0
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
New authorization profile (note 1070261); application-log objects (note 1094041); BAdI interface changes not included
Version: 2.0 Date: 2007/09/17
Page 3 of 22
Configuration Guide for NF-e
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 Fiscaís (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 Fiscaís (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 Fiscaís (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 Fiscaís (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 Fiscaís (NF-e) Assign RFC Dest. for Outbound Messages to Co. Code and Bus. Place VIEW:
J_1BNFE_RFCD_V © 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 4 of 22
Configuration Guide for NF-e
3.1.6 BAdI: General Enhancements for NF-e IMG: Cross-Application Components General Application Functions Nota
fiscal Electronic Notas Fiscaís (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 Fiscaís 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
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 5 of 22
Configuration Guide for NF-e
3.2.2 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 a n 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 nonelectronic NFs.
3.2.3 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
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. © 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 6 of 22
Configuration Guide for NF-e
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: 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) © 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 7 of 22
Configuration Guide for NF-e
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)
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 8 of 22
Configuration Guide for NF-e
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 t ypes 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 Request an authorization to cancel an authorized NF-e Request an authorization to cancel a rejected NF-e Set Contingency per Region or per Business Place Delete NF-e log entries Send NF-e with SCS ' ' (not sent) Set Contingency per NF-e Reset Contingency per NF-e Check XI connection Check NF-e log Display NF-e in NF writer
4.4
Auth. Object F_NFBA F_NFBA F_NFBA F_NFBA F_NFBA F_NFBA F_NFBA no check no check no check
Activity 85 [reverse]) 85 [output]) 85 [reverse]) 35 [output]) 35 [output]) 35 [output]) 35 [output])
Version of XML Layout
Maintain the current version of the XML layout in the I MG 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. I mplement the relevant notes or upgrade to the required support package. The delivery of the XML versions is described in the overview note 989115.
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 9 of 22
Configuration Guide for NF-e
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 t ype. 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 © 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 10 of 22
Configuration Guide for NF-e
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 p ossible 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
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 11 of 22
Configuration Guide for NF-e
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 t ypes 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
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.8.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.8.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.8.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.8.4 Assign internal codes to conditions Transaction J1BTAX to Internal Codes
Condition Setup
Internal code NF_SUBTRIB_BASERED1 NF_SUBTRIB_BASERED1 NF_SUBTRIB_BASERED2 NF_SUBTRIB_BASERED2
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Appl. TX V TX V
Condition Mapping
Assign Conditions
Condition BX45 BX45 BX46 BX46
Version: 2.0 Date: 2007/09/17
Page 12 of 22
Configuration Guide for NF-e
4.9
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 BR CL PY UY AR
Alternate country key 508 512 520 524 528
Brazil Chile Paraguay Uruguay Argentina
In case of using a country code different from those described above, create corresponding entries.
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 13 of 22
Configuration Guide for NF-e
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 fiscaís 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. T he 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 D ANFE (with
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 14 of 22
Configuration Guide for NF-e
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 1
Short text Print output
Program J_1BNFEXMLOUTPARALLEL
FROM routine ENTRY
2) Enhancement of the report J_1BNFEXMLOUTPARALLEL (optional) The report is delivered via support package or implemented with note 1017488. 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) To print the DANFE, create another entry in the IMG activity Nota Fiscal Output Processing Program . For further details, see note 955155.
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.
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 15 of 22
Configuration Guide for NF-e
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) 2) 3) 4)
Request for authorization Submission of a „Contingency“ NF-e Request to authorize the cancellation of an authorized NF-e 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
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 16 of 22
Configuration Guide for NF-e
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) 2) 3) 4) 5) 6) 7)
SEFAZ’ authorization of an NF-e SEFAZ’ rejection of an NF-e SEFAZ’ denial of an NF-e SEFAZ’ authorization to cancel an authorized NF-e SEFAZ’ authorization to cancel a rejected NF-e SEFAZ’ rejection of a request for authorization to cancel an authorized NF-e 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 1 2 3 4 5 6 7
6.4
Message type Authorization of NF-e Rejection of NF-e Denial of NF-e Authorization to Cancel an Authorized NF-e Authorization to Cancel a Rejected NF-e (Skipping) Rejection of a Request for Cancellation Rejection of a Request for Skipping
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. © 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 17 of 22
Configuration Guide for NF-e
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’.
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 18 of 22
Configuration Guide for NF-e
7
Appendix
7.1
Example Coding for BAdI Method CALL_RSNAST00
This Coding can be used after installation of note 1037070. c a l l f u n c t i o n ‘ J _ 1 B NF E_ CA L L _ RS NA ST 0 0 ’ ex po r t i n g i _ac t i v e = i _ac t i v e i _ nf d o c = i _n f d oc e x c ep t i o ns n o _p r i n t e r = 1 o t h er s = 2 . i f s y - s u br c <> 0 . c a l l f u n c t i o n ' J _ 1 B _ NF E_ E RROR_ P ROT OK OL L ' ex po r t i n g i _ d o c n u m = i _ a c t i v e - d o c n u m. e n di f . T h e f u n c t i o n J _ 1 BNF E _ CA L L _ RS NA S T 0 0 i s i n t h e s t a n d a r d d e l i v e r y f o r NF - e . I t p r o v i d e s t h e f o l l o wi n g i n t e r f a c e : I _ A CT I V E
mu s t
a l wa y s b e f i l l e d wi t h f r o m t h e BA DI
i n t e r f a c e.
I _ NF DOC
c a n be f i l l e d f r o m t h e BADI i n t e r a c e wh e n t h e p r i n t e r s h o u l d be d e t e r mi n e d a s ma i n t a i n e d i n t h e o u t p u t c o n f i g u r a t i o n
I _ KA P P L
f o r NF - e t h e d e f a u l t A p p l i c a t i o n ’ NF ’
I _ NA CHA
f o r p r i n t i n g t h e t r a n s mi s s i o n me d i u m mu s t b e s e t t o 1 a s p e r De f a u l t
I _ DI MME
p r i n t i mme d i a t e l y i s p e r d e f a u l t s et t o X , c a n b e s e t Wh e n t h e o u t p u t s h o u l d n ot b e p r i n t e d i mme d i a t e l y
I _ PRI NT E R
c a n b e u s e d wh e n t h e o u t p u t s h o u l d b e s e n d t o a d i f f e r e n t p r i n t e r a s d e f i n e d i n t h e o u t p u t d e t e r mi n a t i o n f o r NF - e
h a s t o be u s e d
t o spac 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 t he routine and activate the source code. * He a d e r d a t a * V B RK - x x x x x = . . . . . . . . . . . .
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 19 of 22
Configuration Guide for NF-e
* I t e m d at a * V B RP - x x x x x = . . . . . . . . . . . . * Ad d i t i o n a l s pl i t c r i t e r i a DA T A : B E GI N OF Z U K , MODUL ( 3 ) V AL UE ' 9 0 1 ' , V T WE G L I K E V B A K - V T WE G, S P AR T L I K E V BA K - S P AR T , 1 V ST EL l I K E VB AP - V ST EL , CONT I NG t y p e j _ 1 b c o n t i n g e n c y , NF T YP E t y p e J _ 1 B NF T YP E, END OF ZUK. DA TA : l l l l l l l l l
v _ b r a n c h t y p e J _ 1 B B RA NC_ , v _ bu kr s t y p e b uk r s , v _ we r k s t y p e we r k s , v _ w e r k s _ d t y p e WE RK S_ d , v _ b r a n c h_ ad dr e s s t y p e s ad r , v _ c on t i n g t y p e j _ 1b c o nt i n ge nc y , v _ v g b el t y p e v g b e l , v _ v gp os t y p e v gp os , v _v s t e l t y pe v s t e l .
Z U K- S P AR T = V B A K - S P A RT . Z U K - V T WE G = V B A K - V T WE G. Z U K- V S T EL = VB A P - V S T EL . * I d en t i f y t h e p l a n t l v _ we r k s = v b a p - w e r k s . i f
n o t l i k p - we r k s i s i n i t i a l . l v _ we r k s = l i k p - we r k s . e n di f . i f
n o t l i p s - we r k s i s i n i t i a l . l v _ we r k s = l i p s - we r k s . e n di f . i f
l v _ we r k s i s i n i t i a l . r a i s e E RROR. e n di f . * I d en t i f y t h e s h i p p i n g p o i n t l v _v s t e l = l i k p- v s t e l . i f l v_v s t e l i s i ni t i al . l v _ v s t e l = v ba p- v s t e l . e n di f . * I d en t i f y t h e p r e v i o us do c an d p os n r l v _ v g b e l = L I P S - V B E L N. l v _ v g p o s = L I PS- p o s n r . i f l v_vgbel i a n d l v _v gp o s l v _ v g b el = l v _ v gp os = e n di f .
s i ni t i al i s i ni t i al . v b a p - V B E L N. v b a p- p os n r .
i f l v_v gpos i s i ni t i al or l v_v gbel i s i ni t i al . r a i s e E RROR. e n di f .
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 20 of 22
Configuration Guide for NF-e
C A L L F U NCT I ON ' J _ 1 B _ B RA NCH _ DE T E RMI NE ' E X P OR T I N G p l a nt = l v _ we r k s I MP ORT I N G branch = l v _ br a nc h E X CE P T I ON S b r a n c h_ n ot _ f o u nd = 01 p l a nt _ no t _ f o un d = 02 v a l u at i o n_ ar e a_ no t _ f o un d = 0 3 c o mp a n y _ n o t _ f o u n d = 04. I F not s y- s ubr c i s i ni t i al . ME SS AGE I D s y - ms g i d T Y PE s y - ms g t y NUMB ER s y - ms g n o WI T H s y - ms g v 1 s y - ms g v 2 s y - ms g v 3 s y - ms g v 4 . E NDI F . l v _ we r k s _ d = l v _ we r k s . C A L L F U NC T I ON ' D E T E RMI N _ B WK E Y _ B U KR S_ F O R_ P L A N T ' E X P OR T I N G we r k = l v _ we r k s _ d I MP ORT I N G b uk r s = l v _ bu k r s .
* * * * *
C A L L F U NC T I ON ' J _ 1 B R EA D _ B RA N CH _ D A T A ' E X P OR T I N G branch = l v _ br a nc h b uk r s = l v _ bu k r s I MP OR T I NG a dd r e s s = l v _ br a nc h _a dd r e s s B R AN CH _ D A T A = C GC _ N U MB E R = A D DR E S S1 = T A BL E S E T _ A DR 6 = E X C EP T I ON S b r a nc h _n ot _ f o un d = 1 a d d r e s s _ n o t _ f o u nd = 2 c o mp a n y _ n o t _ f o u n d = 3 O T H ER S = 4. I F s y - s u br c <> 0. ME SS AGE I D s y - ms g i d T Y PE s y - ms g t y NUMB ER s y - ms g n o WI T H s y - ms g v 1 s y - ms g v 2 s y - ms g v 3 s y - ms g v 4 . E NDI F .
cal l f unct i on ' ex po r t i n g i v _ bu kr s i v _ br a nc h i v _v s t el i v _ c ou nt r y i v _ r e gi o i v _ au ar t i v _ v gb el i v _ v gp os i s _ v ba k i s_vbap i s _l i p s
J _ 1 B _ S D_ NF TY P E_ DE T' = = = = = = = = = = =
l v _ bu k r s l v _b r a nc h l v _v st e l l v _ br a nc h _a dd r e s s - l a nd 1 l v _ br a nc h _a dd r e s s - r e gi o v b ak - a u ar t l v _ vg be l l v _ v gp os v b ak vbap l i ps
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 21 of 22
Configuration Guide for NF-e
i s _l i k p i s _ v bk d i mp o r t i n g ev_nf t ype ev_c ont i ng e x ce pt i o ns er r o r o t h er s
= l i kp = vbkd = Z UK - NF T Y P E = Z UK - CONT I NG = 1 = 2.
i f s y - s u br c <> 0. * ME S S A G E I D S Y - MS GI D T Y P E S Y - MS GT Y N UMB E R S Y - MS GN O * WI T H S Y - MS GV 1 S Y - MS GV 2 S Y - MS GV 3 S Y - MS GV 4 . e n di f . V B RK - Z U KRI
= Z U K.
© 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf
Version: 2.0 Date: 2007/09/17
Page 22 of 22