简体   繁体   中英

How to send/check the status of an IDOC sent to SAP ECC through ALE Audit?

I am working on a Java application that receives Intermediate Documents (IDocs) from ECC and passes iDocs to ECC.

Our application works like a bridge between ECC and other systems, it receives IDocs from ECC that are stored in disk by our application, then a background process is in charge of checking the file system location where the files with the IDocs are saved and later sent to other destinations through HTTP requests. The application also communicates with these other systems to retrieve information that is also saved to files, and then on a background process, to read them and construct IDocs to be sent to ECC.

When the application receives an IDoc from ECC, it sends a confirmation IDoc to ECC, something similar needs to be done when sending to ECC, that is, when the Java application sends IDocs to it, we want ECC to send an ALE confirmation to our application if the IDocs were sent correctly, so our application knows the batch that was sent can be moved to our history folder safely, and in case the confirmation indicates there was a problem, another attempt to send the IDocs should be made.

How can we configure ECC to send a confirmation to our Java application?

The code we use to send from Java to ECC is this:

try {
     destination= JCoDestinationManager.getDestination(PROGID);
     iDocRepository = JCoIDoc.getIDocRepository(destination);
     tid = destination.createTID();
     iDocFactory = JCoIDoc.getIDocFactory();
 } catch (JCoException e) {
     e.printStackTrace();
 }
 List<Invoic02> invoic02s = new ArrayList<>();

 EDI_DC40 edi_dc40 = IdocUtil.generateIdocControlRecordObject(IdocUtil.invoiceIdocType, IdocUtil.invoiceMsgType);

 for(InvoiceIdoc invoicIdoc : invoices){
     Invoic02 invoic02 = new Invoic02();
     invoicIdoc.setBEGIN("1");
     invoicIdoc.setEDI_DC40(edi_dc40);
     invoic02.getInvoiceIdoc().add(invoicIdoc);
 }

 String invoicesIdocString = XmlParser.objectToXmlString(invoices, Invoic02.class);

 try {
     IDocXMLProcessor processor= iDocFactory.getIDocXMLProcessor();
     IDocDocumentList iDocList=processor.parse(iDocRepository, invoicesIdocString.toString());
     JCoIDoc.send(iDocList, IDocFactory.IDOC_VERSION_DEFAULT, destination, tid);
 } catch (JCoException e) {
     e.printStackTrace();
 } catch (IDocParseException e) {
     e.printStackTrace();
 }

To listen to incoming IDOCs we use a private library but it also uses the JCO IDOC library.

Can the JCO IDOC library be used to check on the status of an IDOC sent? Or is there a way to configure ECC to send confirmations of every IDOC it has received?

If you are using standard IDOC input methods (http and function), it is return IDOC save number. So you don't need waiting another IDOC. Just checking IDOC save number in response.

I suppose, checking TID is the only way on Java-side to be sure your IDoc was received successfully. SAP best practice gives us no either ways:

tid = destination.createTID();
...
JCoIDoc.send(iDocList, IDocFactory.IDOC_VERSION_DEFAULT, destination, tid);
destination.confirmTID(tid);
return true;

This line throws errors if something was wrong on the ERP-side.

As I can see in your comment under Suncatcher answer, you want to query the status of the IDoc after it has been processed at ECC side.

First, you are using transactional RFC, so the processing at ECC side is asynchronous, so you have to wait an undefined time until the IDoc is processed by SAP.

Consequently, you have two possibilities:

  • Either your application regularly queries the status of IDocs at ECC side
  • Or you schedule the program RBDSTATE at ECC side, as a background job triggered at regular intervals, which sends confirmations for processed IDocs, and you develop an additional java application which listens to these confirmations. I suggest that you choose the RFC protocol to send the confirmations.
    • RBDSTATE scans the processed IDocs and sends a confirmation IDoc of type ALEAUD01 to the sender system, which contains the numbers of the IDoc processed, their processing status (success, error), messages, business objects created or changed...
    • You have to configure the partner profiles, port, connection data (transaction codes WE20 , WE21 , BD97 , SM59 )
    • You have to develop a new java application which operates as an RFC server, which listens to anything which arrives, and which processes inbound ALEAUD01 IDocs.
    • You may obtain more information in the SAP Library about ALE Audit .
    • Concerning the development of the RFC server application in java, you may obtain more information in the SAP Library about SAP JCO Server Programming .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM