Please also have a look in our OnlineHelp for further information.
The following example shows how to receive a MATMAS IDoc.
As shown in another example (RFC server), an RFCServer object is needed to accept calls from the SAP system. To receive IDocs with the RFCServer object we need to set the property CanReceiveIdocs to true. The event IncomingIdoc is fired when an IDoc is received by ERPConnect.net, so you can use this event to process the IDoc object. The code shows how to initialize and start the RFC Server, and how to install the event.
A reference to an IDoc object is transferred to the event IncomingIdoc. With the segment collection, the content of the IDoc can be analyzed. The first step is to obtain the E2MARAM005 segment. Within this segment, several E2MAKTM001 child segments contain material descriptions. We need to read the data buffer with the ReadData method. The description text is located at index 4 with a length of 40. You can use transaction WE60 or ifr.sap.com to look up IDoc structures. All description texts will be written to the console window
The screenshot below shows the sample program in action. In this case, 7 E2MAKTM001 segments were found so 7 texts are passed.