Retrieve IDoc from SAP

Hello - As a requirement for black box testing, I need to retrieve different types of IDoc documents from SAP. These IDocs are those that have been previously delivered by webMethods to the SAP ‘Inbox’ (they are viewable using the ‘we02’ ‘IDoc list’ function in SAP). Has anyone got an idea how to do this?

I explored the option of writing a custom RFC, but it appears the key constraint why a custom RFC cannot return arbitrary IDoc content is that RFCs cannot have a dynamic output structure. i.e. All IDoc types must be defined in the RFC output.

Just some more info: I’m trying to achieve black-box testing of EAI integration with a SAP system.

The test application first simulates an EAI client submitting a document (say, an XML sales order) to the EAI system. The EAI system converts the XML document to IDoc (ORDERS05 in this case) and delivers to SAP’s IDoc Inbox. After waiting a few seconds for EAI processing, the test application attempts to retrieve the full content of the ORDERS05 IDoc from SAP (using the sales order number as a key) and make assertions on it (for e.g., was order date transformed correctly, does line #2 have such-and-such product ID, etc).

So far, I’ve got a custom RFC (an automation of SAP ‘we19’) that retrieves a list of IDocs matching content search criteria (Sales order number). However, I can’t find a way to retrieve the full IDoc content.

Are these SAP RFCs of any use for getting IDoc content? I can see them from the webMethods SAP adapter, but cannot find documentation online (SAP’s SDN is NOT a great help).

RFC Group

IDOCS_OUTPUT_IN_QRFC
IDOCS_OUTPUT_IN_XML_FORMAT
IDOCS_OUTPUT_TO_FILE EDI7
IDOCS_OUTPUT_TO_INTERNET EDI7
IDOCS_OUTPUT_TO_R2 EDI7
IDOCS_OUTPUT_TO_R3 EDI7
IDOCS_OUTPUT_VIA_XML_HTTP EDI7

This SDN post (requires SDN login) talks about exporting an IDOC to flat file format by using the SAP ‘WE19’ > ‘Inbound File’ function
https://www.sdn.sap.com/irj/scn/message?messageID=1604371#1604371
I’ve tested it and it possible to do the same thing programatically.

This is almost working. While there is no RFC to get a SAP IDoc as XML, our SAP people are using an internal SAP function call to get the XML representation of an IDoc - we plan to use it to return the IDocXML in the output of a custom RFC.

The only issue is that the returned IDocXML does not exactly represent the IDoc as injected into SAP - it adds <EDI_DS40>… </EDI_DS40> tags which contain the status of the IDoc processing within SAP. However, our testing tool can ignore those so that’s OK.