SAPBR Technologies home

SAP in Brazil, explained

XML Tag not mapped correctly

Credit: this text isn’t mine. Renan Correa wrote it for the SPED and NF-e SCN blog (https://scn.sap.com/community/portuguese/sped-and-nf-e). That blog is in Portuguese and this content is too good to miss, so I translated it. All credit goes to Renan and the SAP localization team.

Where to start the analysis

Start with function J_1B_NF_MAP_TO_XML. That’s where mapping begins into the structures sent to the NF-e messaging system (SAP NFE).

What to check

J_1B_NF_MAP_TO_XML reads the ERP tables and does a first mapping into the XML structures (xmlh for header, xmli for items).

Set a breakpoint at the “RFC” statement. When you run the program, it stops at the call to function /XNFE/OUTNFE_CREATE.

There, check whether tables and structures GT_RFC* and GS_RFC* hold the right data. If they do, the problem is in the SAP NFE mapping. If the data is missing or wrong, the problem is in the SAP ERP mapping.

SAP screen: What to check

For layout 3.10 specifically, the final mapping happens in perform call_message_system_comm, where the xml* structures are mapped to GT_RFC* and GS_RFC*, which are sent to SAP NFE.

SAP screen: What to check

At the end of call_message_system_comm, SAP NFE is called through function /XNFE/OUTNFE_CREATE.

SAP screen: What to check

To find where a field is filled in SAP ERP, search “in main program” for the XML tag (or the ERP field or structure) and display the line that fills it.

SAP screen: What to check

In SAP ERP, the structures are filled in three ways:

  1. From the J_1BNF* tables and master data
  2. Calculated at runtime from tables
  3. BAdIs

The screenshots below show where the header and item methods are called:

SAP screen: What to check
SAP screen: What to check
SAP screen: What to check

At the end of processing, the program calls SAP NFE with function /xnfe/outnfe_create:

SAP screen: What to check

In SAP NFE, the program receives the ERP data and runs the technical validation in function /xnfe/outvalidation. If everything passes, it moves to function /xnfe/outnfe_transform, where the proxy structures are filled:

SAP screen: What to check

In form fill_proxy_structure, the program checks what ERP sent and maps the relevant fields to the XML hierarchy. The proxy then converts it to XML in the next step:

SAP screen: What to check

That’s all for today. Again, all credit to Renan Correa and the SAP Brazil localization team for putting these details together.

SAP screen: What to check

Comments

Leave a Reply