+ All Categories
Home > Documents > NFe_CustGuide_V2_0

NFe_CustGuide_V2_0

Date post: 07-Nov-2014
Category:
Upload: rafael-soares
View: 104 times
Download: 8 times
Share this document with a friend
Popular Tags:
22
Configuration Guide for NF-e © 2008 SAP Dietmar-Hopp Allee 16 D-69190 Walldorf Version: 2.0 Date: 2007/09/17 Page 1 of 22 NF-e of SEFAZ – Phase 2 System Configuration Version 2.0 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 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
Transcript
Page 1: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 1 of 22

NF-e of SEFAZ – Phase 2

System ConfigurationVersion 2.0

Note 1018098

Table of Content:

1 Introduction ....................................................................................................... 32 Document History.............................................................................................. 33 Overview........................................................................................................... 4

3.1 New IMG Activities................................................................................... 43.1.1 Assign XML Version to Region ........................................................... 43.1.2 Define SEFAZ Status Codes ............................................................... 43.1.3 Maintain Number Ranges for NF-e..................................................... 43.1.4 Define NF Type Redetermination for Goods Movements..................... 43.1.5 Assign RFC Dest. for Outbound Msg to Co. Code and Bus. Place ...... 43.1.6 BAdI: General Enhancements for NF-e .............................................. 53.1.7 Define NF Type Redetermination per Business Place ......................... 53.1.8 Define NF Type Redetermination per State......................................... 53.1.9 BAdI: Redetermination of Nota Fiscal Type per Line Item.................. 5

3.2 Enhanced IMG Activities ........................................................................... 53.2.1 Define Nota Fiscal Types ................................................................... 53.2.2 Assign Numbering and Printing Parameters....................................... 63.2.3 Define IPI Tax Laws........................................................................... 6

3.3 New Business Add-In CL_NFE_PRINT .................................................... 63.3.1 BAdI Method: RESET_SUBRC........................................................... 63.3.2 BAdI Method: CHECK_SUBSEQUENT_DOCUMENTS .................... 63.3.3 BAdI Method: FILL_HEADER ........................................................... 73.3.4 BAdI Method: FILL_ITEM ................................................................. 73.3.5 BAdI Method: CALL_RSNAST00........................................................ 7

3.4 New Business Add In CL_SD_NFTYPE.................................................... 73.4.1 BAdI Method: MODIFY ..................................................................... 7

4 Required Configurations .................................................................................... 94.1 Creation of NF types for NF-e.................................................................... 94.2 Maintain Number Ranges for external NF-e number .................................. 94.3 Authorization: User Actions in NF-e Monitor ............................................ 94.4 Version of XML Layout............................................................................. 94.5 Contingency settings .................................................................................10

4.5.1 Determination of number range in SD and MM .................................104.5.2 Determination of the contingency printer in MM ...............................10

Page 2: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 2 of 22

4.5.3 Determination of the contingency printer in SD.................................114.6 SD: NF-Type Determination .....................................................................114.7 MM: NF-Type Redetermination for Goods Movements ............................124.8 CBT: Mapping of SubTrib Base Reduction ...............................................12

4.8.1 Create new conditions for MM & SD.................................................124.8.2 Maintain calculation procedure TAXBRA..........................................124.8.3 Create new internal codes .................................................................124.8.4 Assign internal codes to conditions....................................................12

4.9 Maintain Alternate County Key.................................................................135 Optional Configurations....................................................................................14

5.1 RFC Destination .......................................................................................145.2 Maintenance of SEFAZ Status Codes........................................................145.3 Automated Printing of DANFE .................................................................145.4 Transition Phase........................................................................................145.5 IPI Tax Situation for outgoing NFs ...........................................................155.6 Authorization: Access to NF-e Monitor.....................................................15

6 Communication with Messaging System...........................................................166.1 Interface for Outbound Messages ..............................................................166.2 Interfaces for Inbound Messages ...............................................................176.3 Message Type of Inbound Message...........................................................176.4 Backend Control .......................................................................................176.5 Messaging-System Control .......................................................................17

7 Appendix ..........................................................................................................197.1 Example Coding for BAdI Method CALL_RSNAST00............................197.2 Routine 901 ..............................................................................................19

Page 3: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 3 of 22

1 IntroductionThe delivery of the functionality for electronic Notas Fiscaís (NF-e) is described inthe overview note 989115.The solution for SEFAZ’ NF-e comprises two parts: (a) an integration of NF-eprocess logic into the application logic of the SAP backend and (b) a solution for amessaging system supporting the implementation in the backend.

This configuration guide describes the mandatory and optional system configurationsrelevant for “NF-e of SEFAZ” in the backend. It also gives the information relevantfor a solution on the messaging-system side in order to complement and properlyinteract with the SAP backend.

2 Document History

HistoryVersion Date Comment (Author)1.0 2007-02-22 Delivered with development phase 2 – note 9802132.0 2007-09-17 New authorization profile (note 1070261); application-log objects

(note 1094041); BAdI interface changes not included

Page 4: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 4 of 22

3 OverviewThis 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 subsequentsections Required Configurations and Optional Configurations.

3.1 New IMG Activities

3.1.1 Assign XML Version to RegionIMG:Cross-Application Components General Application Functions Nota fiscal

Electronic Notas Fiscaís (NF-e) Assign XML Version to RegionVIEW:J_1BNFE_XMLV_V

3.1.2 Define SEFAZ Status CodesIMG:Cross-Application Components General Application Functions Nota fiscal

Electronic Notas Fiscaís (NF-e) Define SEFAZ Status CodesVIEW:J_1BSTSCODEV

3.1.3 Maintain Number Ranges for NF-eIMG:Cross-Application Components General Application Functions Nota fiscal

Electronic Notas Fiscaís (NF-e) Maintain Number Ranges for NF-eTRANSACTION:J1BI_NFE

3.1.4 Define NF Type Redetermination for Goods MovementsIMG: Cross-Application Components General Application Functions Notafiscal Electronic Notas Fiscaís (NF-e) Define NF Type Redetermination forGoods MovementsVIEW:J_1BNFTYPEREDMMV

3.1.5 Assign RFC Dest. for Outbound Msg to Co. Code and Bus. PlaceIMG: Cross-Application Components General Application Functions Notafiscal Electronic Notas Fiscaís (NF-e) Assign RFC Dest. for OutboundMessages to Co. Code and Bus. PlaceVIEW:J_1BNFE_RFCD_V

Page 5: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 5 of 22

3.1.6 BAdI: General Enhancements for NF-eIMG: Cross-Application Components General Application Functions Notafiscal Electronic Notas Fiscaís (NF-e) Business Add-Ins BAdI: GeneralEnhancements for NF-eBAdI Definition:CL_NFE_PRINT ( transaction SE18)

3.1.7 Define NF Type Redetermination per Business PlaceIMG:Cross-Application Components General Application Functions Nota fiscal

Sales and Distribution - Billing Documents Define Redetermination of NotaFiscal Type per Business PlaceVIEW:J_1B_NFTYPEBRCHV

3.1.8 Define NF Type Redetermination per StateIMG:Cross-Application Components General Application Functions Nota fiscal

Sales and Distribution - Billing Documents Define Redetermination of NotaFiscal Type per StateVIEW:J_1B_NFTYPEREGV

3.1.9 BAdI: Redetermination of Nota Fiscal Type per Line ItemIMG:Cross-Application Components General Application Functions Nota fiscal

Sales and Distribution - Billing Documents BAdI: Redetermination of NotaFiscal Type per Line ItemBAdI Definition:CL_SD_NFTYPE ( transaction SE18)

3.2 Enhanced IMG Activities

3.2.1 Define Nota Fiscal TypesIMG:Cross-Application Components General Application Functions Nota fiscalDefine Nota Fiscal TypesEnhancements:

1) New flag Electronic NF – Characterizes the NF type as an NF type for electronicNotas Fiscaís

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

Page 6: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 6 of 22

3.2.2 Assign Numbering and Printing ParametersIMG:Cross-Application Components General Application Functions Nota fiscalOutput Assign Numbering and Printing ParametersVIEW:J_1BB2VEnhancements:

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.3 Define IPI Tax LawsIMG:Financial Accounting Financial Accounting Global Settings Tax onSales/Purchases Basic Settings Brazil Define IPI Tax LawsVIEW:J_1BB2VEnhancements:

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

3.3 New Business Add-In CL_NFE_PRINTSee IMG Activity: BAdI: General Enhancements for NF-e

3.3.1 BAdI Method: RESET_SUBRCUse: Printing of the DANFE without authorization codeImporting: IS_NFDOC (NF Document Header)Exporting: CH_SUBRCBased on the data of the NF document header, logic can be implemented to decide ifthe DANFE should be printed without authorization code. If this is the case theexported parameter CH_SUBRC must be set to 0.

3.3.2 BAdI Method: CHECK_SUBSEQUENT_DOCUMENTSUse: Block the sending of a request to cancel/skip and NF-eImporting: IS_ACTIVE (Current NF-e status – entry in table J_1BNFE_ACTIVE)Exporting: CH_SUBRCBased on the data of the current NF-e status, logic can be implemented to check if arequest for authorization to cancel or skip an NF-e should be blocked. If this is thecase, the output parameter CH_SUBRC must be set to 1.

Page 7: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 7 of 22

3.3.3 BAdI Method: FILL_HEADERUse: Fill NF-e header data used in the XML outbound messageImporting: IN_DOC (NF-e Header)Exporting: OUT_HEADER

OUT_COBRANCAThis method allows:

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

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

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

3.3.4 BAdI Method: FILL_ITEMUse: Fill NF-e item data used in the XML outbound messageImporting: IN_DOC (NF-e Header)

IN_LIN (NF-e Item data)IN_TAX (NF-e Tax data)

Exporting: OUT_ITEMOUT_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_RSNAST00Use: Fill NF-e item data used in the XML outbound messageImporting: I_ACTIVE (NF-e Current Status)This method allows:

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

3.4 New Business Add In CL_SD_NFTYPESee IMG Activity: BAdI: Redetermination of Nota Fiscal Type per Line Item

3.4.1 BAdI Method: MODIFYUse: 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)

Page 8: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 8 of 22

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)

Page 9: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 9 of 22

4 Required ConfigurationsThis section gives a description of all mandatory system configurations. You will finda subsection per configuration “topic”.

4.1 Creation of NF types for NF-eThe system recognizes an NF-e process based on the assigned NF type. For NF-eprocesses, 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 numberNew number ranges for the external NF-e number you define per number-range groupin the IMG activity Maintain Number Ranges for NF-e.

4.3 Authorization: User Actions in NF-e MonitorUser actions in the NF-e Monitor (transaction J1BNFE) are subject to authorizationchecks. The authorization object F_NFBA involved is available with note 687829.

User Action Auth. Object ActivityRequest 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 checkCheck NF-e log no checkDisplay NF-e in NF writer no check

4.4 Version of XML LayoutMaintain the current version of the XML layout in the IMG activity Assign XMLVersion 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 ispassed via the outbound interface to the messaging system. Based on the layout, themessaging system maps the NF-e data to the XML message structure.The XML version does not impact the backend logic. You must ensure that theversion you maintain is supported by the backend. Implement the relevant notes orupgrade to the required support package. The delivery of the XML versions isdescribed in the overview note 989115.

Page 10: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 10 of 22

If you need different XML versions within one state, you must implement the methodBAdI Method: FILL_HEADER of the Business Add-In CL_NFE_PRINT to overwritethe 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 thesame region communicate with different SEFAZ systems (for production and fortesting) that require different versions.

4.5 Contingency settingsThis section considers NF-es that have been posted under normal process conditionsand are switched to contingency.Whenever you decide to continue a business process in contingency, i.e., to print therelated, already created invoice without prior authorization by the government youmust decide if you want to print the invoice as an electronic NF or as a non-electronicNF. Electronic contingency NFs are to be printed on security paper using a laserprinter. In this case, the NF model, e.g., 55 and the NF-e number range remainunchanged. Non-electronic NFs are printed on dot-matrix printers. NF model and NFnumber range change. In any case, the initial NF must be cancelled together with thesource document from SD, MM, or IV and a new NF must be posted.

4.5.1 Determination of number range in SD and MMCase 1: Printing on security paper as NF-e

To keep the model and the number range, set the indicator Numbering Contin. in thesub-area NF-e for the relevant entry in the IMG activity Assign Numbering andPrinting Parameters.Case 2: Printing as classical NF

Do not set the indicator Numbering Contin. in the sub-area NF-e for the relevant entryin the IMG activity Assign Numbering and Printing Parameters. Instead, assign acontingency NF type to the electronic NF type in the field NF Contin. Type in theIMG activity Define Nota Fiscal Types. The contingency NF type must not have theindicator 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 therelevant entry of the IMG activity Assign Numbering and Printing Parameters in thefield No. range no. of the sub-area Normal NF.

4.5.2 Determination of the contingency printer in MMCase 1: Printing on security paper as NF-e

Maintain the contingency printer, which in this case must be a laser printer in the IMGactivity Assign Numbering and Printing Parameters in the field Output Device of thesub-area NF-e.

Case 2: Printing as classical NFDo not maintain a printer as described in case 1. Instead, assign a contingency NFtype to the electronic NF type in the field NF Contin. Type in the IMG activity Define

Page 11: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 11 of 22

Nota Fiscal Types. The determination of the dot-matrix printer is then done based onthe configurations related to the non-electronic contingency NF type.

4.5.3 Determination of the contingency printer in SDCase 1: Printing on security paper as NF-e

You can maintain the contingency printer, which in this case must be a laser printer inthe field Output Device of the sub-area NF-e of the IMG activity Assign Numberingand Printing Parameters.Alternatively, you can configure the contingency printer using the classical printerconfiguration.Case 2: Printing as classical NF

Do not maintain a printer as described in case 1. Instead, assign a contingency NFtype to the NF type of the initial NF-e. You can specify the contingency NF type inthe field NF Contin. Type in the IMG activity Define Nota Fiscal Types. Thecontingency NF type must not have the indicator Electronic NF set.

4.6 SD: NF-Type DeterminationTwo new maintenance views are available to enhance the classic Nota Fiscal Typedetermination 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 aNota 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 NFtype 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 methodMODIFY of the BAdI CL_SD_NFTYPE. With this BAdI method it is possible toassign a NF type at line-item level during the billing process. Consequence: Thesystem induces a billing document split to ensure that only line items having the sameNF type are included in a billing document. To support this feature the user mustmaintain the billing document data transport routine 901 (coding in the appendix) forthe relevant entries in the following IMG activities:

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

Page 12: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 12 of 22

4.7 MM: NF-Type Redetermination for Goods MovementsIn case of goods movements, the NF type is determined from the movement type. Theexisting assignment of NF types to movement type in the IMG activity MaterialsManagement Inventory Management and Physical Inventory Nota FiscalMaintain Nota Fiscal Category Derivation remains unchanged.Assign NF-e types to MM movement types per plant in the IMG activity Define NFType Redetermination for Goods Movements. A duplication of movement types forNF-e processes is not necessary.

A configuration in the IMG activity Define NF Type Redetermination for GoodsMovements is thus required for those plant and business transactions (movementtypes) that are subject to NF-e processing.

4.8 CBT: Mapping of SubTrib Base ReductionThe configurations described in this section are only relevant if condition-based taxcalculation used for Brazilian company codes.

4.8.1 Create new conditions for MM & SDTransaction J1BTAX Condition Setup Condition typesCopy BX44 to BX45 Short text: BRSubTrib NF Basred1Copy BX45 to BX46 Short text: BRSubTrib NF Basred2

4.8.2 Maintain calculation procedure TAXBRATransaction 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 codesTransaction J1BTAX Condition Setup Condition Mapping Internal CodesNF_SUBTRIB_BASERED1 Federal base reduction Rate for SubtribNF_SUBTRIB_BASERED2 State base reduction Rate for Subtrib

4.8.4 Assign internal codes to conditionsTransaction J1BTAX Condition Setup Condition Mapping Assign Conditionsto Internal CodesInternal code Appl. ConditionNF_SUBTRIB_BASERED1 TX BX45NF_SUBTRIB_BASERED1 V BX45NF_SUBTRIB_BASERED2 TX BX46NF_SUBTRIB_BASERED2 V BX46

Page 13: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 13 of 22

4.9 Maintain Alternate County KeyWith the alternate country key, the IGBE country code is determined and set for theXML File.IMG:General Settings Set countries Define countries in R/3 SystemsIn the detail view insert:

Country Alternate country keyBR 508 BrazilCL 512 ChilePY 520 ParaguayUY 524 UruguayAR 528 Argentina

In case of using a country code different from those described above, createcorresponding entries.

Page 14: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 14 of 22

5 Optional ConfigurationsThis section gives a description of all optional system configurations. You will find asubsection per configuration “topic”.

5.1 RFC DestinationThe default RFC destination is ENF_BR_2006.

The RFC destination ENF_BR_2006 is hard-coded. If you want to use a differentRFC destination, you need to maintain it in the IMG activity Assign RFC Dest. forOutbound Messages to Co. Code and Bus. Place.The link between the RFC destination (input channel of the messaging system) andthe respective government system for production or testing needs to be defined in themessaging system.

5.2 Maintenance of SEFAZ Status CodesSEFAZ sends a status code with each response message. These codes provideinformation about the reason for a particular response, e.g., the reason for a rejectionof an authorization request.

The SEFAZ status code is a mandatory field of the inbound interface from themessaging system to the backend. The maintenance of status codes with description ispossible but not mandatory. Independent of the definition of status codes in the IMGactivity Define SEFAZ Status Codes the code itself (not the description) is stored inthe NF-e data base.

5.3 Automated Printing of DANFEWhen 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-eimmediately; you must first wait for authorization from SEFAZ. Once SEFAZapproves your NF-e and returns a corresponding protocol number, the system does notprint 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 triggerautomatic printing of the NF-e upon receipt of authorization from SEFAZ. You canfind an example coding in the appendix of this document.

5.4 Transition PhaseDuring a transition phase from classical NF posting to NF-e processing, the legallyrelevant notas fiscaís are non-electronic, i.e., of model 1/1A. However, the NF data issent to SEFAZ as an XML message as if the posted NF was an NF-e. The model inthe XML message must be 55. The NF number is the 6-digit non-electronic number. Itis not required to receive an authorization prior to printing the NF. The DANFE (with

Page 15: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 15 of 22

or without protocol number) must be printed and together with the NF of model 1/1Abe 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 activityNota Fiscal Output Processing Program:Medium Short text Program FROM routine1 Print output J_1BNFEXMLOUTPARALLEL ENTRY2) Enhancement of the report J_1BNFEXMLOUTPARALLEL (optional)

The report is delivered via support package or implemented with note 1017488. Youmay 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, insertthe z-report in the IMG activity processing program.

3) Maintain an RFC destination for the parallel phase and link it to the test system ofthe government (configuration of the messaging system). See chapter “RFCDestination”.4) To print the DANFE, create another entry in the IMG activity Nota FiscalOutput Processing Program. For further details, see note 955155.

5.5 IPI Tax Situation for outgoing NFsThe XML layout contains separate fields for the IPI tax situation for incoming andoutgoing NF-es. You can maintain an IPI tax situation for outgoing NF-es that isdifferent from the IPI tax situation for incoming NF-es. You do that in the IMGactivity Define IPI Tax Laws in the field Tax Sit. IPI Ou. If you do not maintain anentry in this field, the system will take the entry maintained in the field Tax Sit. IPI Infor both, incoming and outgoing NF-es.

5.6 Authorization: Access to NF-e MonitorThe 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 thisnote. If authorization checks are activated, only users who have the authorizationobject F_NFBA, activity 03 [display] assigned to their authorization profile canaccess the NF-e Monitor via transaction J1BNFE. This is the same authorization asrequired to use the NF-writer display transaction J1B3N.

Page 16: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 16 of 22

6 Communication with Messaging SystemThis section gives a description of the backend functionalities that are relevant for thecommunication between backend and messaging system, e.g., the SAP ExchangeInfrastructure (XI). Corresponding settings and configuration of the messaging systemis mandatory.

6.1 Interface for Outbound MessagesThe 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 thecurrently valid XML layout together with the NF-e document status (DS), the NF-esystem communication status (SCS), and the contingency flag. The messaging systemhas the task to map the NF-e data to the layout structure of the XML file. The NF-edocument status and the NF-e system communication status contain the informationabout the type of outbound message, which could be one of the following:

1) Request for authorization2) Submission of a „Contingency“ NF-e3) Request to authorize the cancellation of an authorized NF-e4) Request to skip the number of a rejected NF-e

The identification of the different types of outbound messages is given by the value ofthe following interface fields

XML_IN- DOCSTATXML_IN- SCSSTATXML_IN- CONTINGas 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 thecancellation of an authorized NF-e

1 1 Initial

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

2 3 initial

Page 17: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 17 of 22

6.2 Interfaces for Inbound MessagesThe back end can receive messages via the inbound interfaces:

J_1B_NFE_XML_IN (Function Module) – single NF-e processingJ_1B_NFE_XML_IN_TAB (Function Module) – batch NF-e processingThe inbound interfaces can process any of the following message types:

1) SEFAZ’ authorization of an NF-e2) SEFAZ’ rejection of an NF-e3) SEFAZ’ denial of an NF-e4) SEFAZ’ authorization to cancel an authorized NF-e5) SEFAZ’ authorization to cancel a rejected NF-e6) SEFAZ’ rejection of a request for authorization to cancel an authorized NF-e7) SEFAZ’ rejection of a request for authorization to cancel a rejected NF-e

Protocol number, SEFAZ status code, and the message type are mandatory importingparameters. In addition, the access key of the NF-e or alternatively the SAP internalNF-e document number (if the NF-e was created by the SAP backend, the internaldocument number is in stored in the random-number field of the access key) must bepassed to the backend.

6.3 Message Type of Inbound MessageThe backend expects a unique code identifying the type of inbound message. Thesecodes are defined in the backend. The supported message types and their respectivecodes are:

Message code Message type1 Authorization of NF-e2 Rejection of NF-e3 Denial of NF-e4 Authorization to Cancel an Authorized NF-e5 Authorization to Cancel a Rejected NF-e (Skipping)6 Rejection of a Request for Cancellation7 Rejection of a Request for Skipping

6.4 Backend ControlImportant: with the current solution, the backend assumes an NF-e message hasreached 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 leadto an inconsistency of data between the backend and SEFAZ. Neither should themessaging system switch an NF-e received from the backend to contingency.

6.5 Messaging-System ControlThe messaging system can activate and deactivate contingency in the backend onbusiness-place level.

Page 18: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 18 of 22

This is possible via the remote-enabled function moduleJ_1B_NFE_CONTINGENCY_SET.In the interface, the messaging system must specify the fields LAND1, BUKRS, andBRANCH. The field REGIO must remain initial. The messaging system may select ordeselect the indicator AS_OUT. This indicator is interpreted by the backend. If it isset, the backend switches to contingency for any subsequent NF-e posting. Theindicator can be automatically deactivated through the messaging system or manuallyby a user with the required authorization profile.IMPORTANT: If the function module J_1B_NFE_CONTINGENCY_SET is calledremotely by the messaging system, the importing parameter IV_FIRE_COMMITmust be set to ‘X’.

Page 19: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

Page 19 of 22

7 Appendix

7.1 Example Coding for BAdI Method CALL_RSNAST00This 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 bedetermined 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 perDefault

I_DIMME print immediately is per default set to X, can bes et to spaceWhen the output should not be printed immediately

I_PRINTER can be used when the output should be send to a differentprinter as defined in the output determination for NF-e

When during the BADI process error occurs, the messages are written in the error logand can be controlled with the report J_1BNFE_MONITOR.

7.2 Routine 901Create a new Data Transport Routine, e.g., with the routine no. 901 and thedescription NF split by NFtypeCopy the following source code into the routine and activate the source code.

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

Page 20: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

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 plantlv_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 pointlv_vstel = likp-vstel.

if lv_vstel is initial. lv_vstel = vbap-vstel.endif.

* Identify the previous doc and posnrlv_vgbel = LIPS-VBELN.lv_vgpos = LIPS-posnr.

if lv_vgbel is initialand lv_vgpos is initial. lv_vgbel = vbap-VBELN. lv_vgpos = vbap-posnr.endif.

if lv_vgpos is initialor lv_vgbel is initial. raise ERROR.endif.

Page 21: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

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

Page 22: NFe_CustGuide_V2_0

Configuration Guide for NF-e

© 2008 SAPDietmar-Hopp Allee 16D-69190 Walldorf

Version: 2.0Date: 2007/09/17

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.


Recommended