Skip to end of metadata
Go to start of metadata

CCe Rejection - Missing fields - Workaround

Applies to:

SAP SLL-NFE 1.0 SP 19

Summary

Some SEFAZ webservices send missing fields as a return from a rejected CC-e request. When inbound proxy received the message with missing fields a dump is generated. This wiki will help you implement a temporary solution while SEFAZ webservices are not fixed. As a recomendation, please open a service request to the related SEFAZ requesting them to send those fields.

Author(s):  Diogo Awaihara

   
Company:     Sonda Procwork
Created on:    Aug 24, 2011
Author(s) Bio
Diogo Awaihara is a PI and ABAP developer working for Sonda Procwork.

Table of Contents

1. Concept

When SEFAZ don't send chNFe, nSeqEvento or tpEvento fields inbound proxy generates a dump error. To fix that, those missing fields have to be populated, reading them from the Request Message just like the standard does to idLote through BPM EVENT_ReceiptProcess.

The Request Message (nfeRecepcaoEvento) has all XML of Events sent to SEFAZ (field /nfeRecepcaoEvento/nfeDadosMsg/envEvento/evento).
Basically the Message Mapping has to check if the required field does not exist into the Response message from SEFAZ and if so, get the this value from the Request Message, from within XML in field /nfeRecepcaoEvento/nfeDadosMsg/envEvento/evento. So, we will create three UDFs: one to populate a global variablecontaining an array of all XMLs from evento field (request message), other one to keep control an index which will be used to determine which Event is being mapped, and one last UDF which will read the array using the current index value and get the missing field from inside the XML into the array.

2. Message Mapping

Structure

First of all we have to create a message mapping which will merge fields from Request Message into the Response Message (just like the standard mappingEVENT_nfeRecepcaoEvento_Merge_nfeRecepcaoEventoResponse_TO_nfeRecepcaoEventoResponse).

Java Sections

Declare a Global Vector which will contain all XMLs from evento field (from Request Message).

3. UDF

To implement this workaround we will have to create three UDF: set_eventos_and_return_lote, Retorna_valor_incrementa_indice, and get_chNFe.

set_eventos_and_return

Create a Queue UDF with two Arguments: eventos and lote.

The code will basically populate the global Vector with all XMLs from the evento field (from Request message field /nfeRecepcaoEvento/nfeDadosMsg/envEvento/evento) and return idLote (from Request Message field /nfeRecepcaoEvento/nfeDadosMsg/envEvento/idLote):

Retorna_valor_incrementa_indice

This one will only Add 1 to an index variable in Global Container (should be implemented as a Global Variable as well) and return the Value from Argument a:
Code:

get_chNFe

This last UDF will read the XML from Vector lt_eventos using index from Global Container and get chNFe field within this XML. It does not need any Argument:

Imports: com.sap.aii.mapping.api.;javax.xml.parsers.;java.io.;org.xml.sax.;java.util.;org.w3c.dom.;com.sap.aii.mapping.lookup.;java.lang.reflect.;javax.xml.transform.TransformerException;

Code:

4. Mapping

idLote

Call set_eventos_and_return_lote using Arguments "evento" and "idLote" (from structure /nfeRecepcaoEvento/nfeDadosMsg/envEvento/):

retEvento

Call UDF Retorna_valor_incrementa_indice:

chNFe

Check if chNFe exists and, if not, call get_chNFe to get chNFe from Request Message:

Related Content

http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mappingtool/tf7/rt/GlobalContainer.htmlhttp://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=230458719

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=230458719

http://forums.sdn.sap.com/thread.jspa?messageID=10562469

Useful Information

CC-e; Rejection; Rejeição; Missing fields; error; erro; sefaz;