Receive an IDoc
This section shows how to receive and process a MATMAS IDoc.
To configure your SAP system to send MATMAS IDocs, see Set Up a Test Environment for IDocs.
About
The following sample receives a MATMAS IDoc that contains material descriptions. The material descriptions are written into the console window to check the contents of the IDoc.
The MATMAS IDoc is analyzed using the E2MARAM005 segment. Within this segment, several E2MAKTM001 child segments contain material descriptions.
Tip
You can use the transaction WE60 to look up the structures of IDocs in SAP.
Receive a MATMAS IDoc
Follow the steps below to receive a MATMAS IDoc:
- Create an RFC Server object to accept calls from SAP, see RFC Server for more information.
- To receive IDocs with the RFCServer object, set the property
CanReceiveIdocs
to true. - When an IDoc is received by ERPConnect, the event
IncomingIdoc
is triggered and a reference to the RFCServer object and to the IDoc object is transferred. - Use the
IncomingIdoc
event to read the data buffer of the child segment E2MAKTM001. The description text is located at index 4 with a length of 40 in E2MAKTM001. - Write the description texts into the console window.
- Run the program.
- Send an IDoc in SAP and check the result.
Output:
In this case, 5 E2MAKTM001 segments were found so 5 texts are passed.
Note
If you do not want to read the data buffer with offset and length of the texts, you can load an XML Schema instead, see Using XMLs for IDocs.