Вы находитесь на странице: 1из 22

Configuration Guide for NF-e

NF-e of SEFAZ Phase 2 System Configuration


Version 2.0

Note 1018098

Table of Content: 1 2 3 Introduction ....................................................................................................... 3 Document History.............................................................................................. 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 Assign Numbering and Printing Parameters....................................... 6 3.2.3 Define IPI Tax Laws........................................................................... 6 3.3 New Business Add-In CL_NFE_PRINT .................................................... 6 3.3.1 BAdI Method: RESET_SUBRC........................................................... 6 3.3.2 BAdI Method: CHECK_SUBSEQUENT_DOCUMENTS .................... 6 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.................................................... 7 3.4.1 BAdI Method: MODIFY ..................................................................... 7 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 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

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 CBT: Mapping of SubTrib Base Reduction ...............................................12 4.8.1 Create new conditions for MM & SD.................................................12 4.8.2 Maintain calculation procedure TAXBRA..........................................12 4.8.3 Create new internal codes .................................................................12 4.8.4 Assign internal codes to conditions....................................................12 4.9 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

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

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.

Document History

History
Version Date 1.0 2.0 Comment (Author) Delivered with development phase 2 note 980213 New authorization profile (note 1070261); application-log objects (note 1094041); BAdI interface changes not included

2007-02-22 2007-09-17

2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf

Version: 2.0 Date: 2007/09/17

Page 3 of 22

Configuration Guide for NF-e

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 Electronic Notas Fiscas (NF-e) Define SEFAZ Status Codes
VIEW:

Nota fiscal

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


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

J_1BNFTYPEREDMMV

3.1.5 Assign RFC Dest. for Outbound Msg to Co. Code and Bus. Place
IMG: Cross-Application Components

fiscal Electronic Notas Fiscas (NF-e) Messages to Co. Code and Bus. Place
VIEW:

General Application Functions Nota Assign RFC Dest. for Outbound

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


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

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
IMG:

Enhanced IMG Activities

3.2.1 Define Nota Fiscal Types


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

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

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 Output Assign Numbering and Printing Parameters
VIEW:

Nota fiscal

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 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 Version: 2.0 Page 6 of 22 Dietmar-Hopp Allee 16 Date: 2007/09/17 D-69190 Walldorf

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

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 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 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])

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.

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 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 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 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 Control for billing documents document IMG: Sales and Distribution Control for billing documents document Billing Billing Documents Maintain Copying Copying control: Sales document to billing Billing Billing Documents Maintain Copying Copying control: Delivery document to billing

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 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

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 Condition Mapping Assign Conditions

Internal code NF_SUBTRIB_BASERED1 NF_SUBTRIB_BASERED1 NF_SUBTRIB_BASERED2 NF_SUBTRIB_BASERED2

Appl. TX V TX V

Condition BX45 BX45 BX46 BX46

2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf

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 Country BR CL PY UY AR

Set countries

Define countries in R/3 Systems

In the detail view insert: Alternate country key 508 Brazil 512 Chile 520 Paraguay 524 Uruguay 528 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

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 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

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 (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

DOCSTAT
initial initial 1 2

SCSSTAT
0 0 1 3

CONTING
initial X Initial 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 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

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. 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
7.1

Appendix
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 I_NFDOC I_KAPPL I_NACHA I_DIMME I_PRINTER must always be filled with from the BADI interface. can be filled from the BADI interace when the printer should be determined as maintained in the output configuration for NF-e the default Application NF has to be used for printing the transmission medium must be set to 1 as per Default print immediately is per default set to X, can bes et to space When the output should not be printed immediately 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 = ............

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

* 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.

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

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

* * * * *

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

is_likp is_vbkd importing ev_nftype ev_conting exceptions error others

= likp = vbkd = ZUK-NFTYPE = ZUK-CONTING = 1 = 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.

2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf

Version: 2.0 Date: 2007/09/17

Page 22 of 22

Вам также может понравиться