As shown in another example (RFC Server) an RFC Server 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, 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.
Click to open C# example.Click to open VB example.
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 ReadDataBuffer method. The description text is located at index 4 with a length of 40. You can use transaction WE60 to look up IDoc structures. All description texts will be written to the console window.