Please also have a look in our OnlineHelp for further information.
We have already discussed IDoc handling in another sample. This time we want to create a more complex IDoc type: ORDERS01. This IDoc will create a sales order in the SAP system.
There are some things to do before sending this type of IDoc. Please refer to the administra-tion chapter to learn how to configure a correct partner profile. If there is no partner profile found for an incoming IDoc, no order will be created.
There are two possible ways to create an IDoc object after having established a connection to the SAP system. Use the CreateIdoc method to create an IDoc with all segments located in the segment collections. This might be useful for sending very simple IDocs. In this example we use the CreateEmptyIdoc method to create only the segments we need with the CreateSegment method.
The example below is a simple WinForms application with two textboxes: The material number (txtMaterialNumber) and the quantity (txtQty) can be entered by the user.
Our sample IDoc needs three different kinds of segment types:
E1EDK01 is the main segment of an ORDERS01 IDoc. We leave it empty, but it must be provided by the calling program to pass the SAP IDoc syntax check.
E1EDP01 is the segment for a single order position. The field MENGE contains the quantity. Of course, this segment can occur more than once.
E1EDP19 represents an object definition. In this case the object is a material number. The field QUALF is therefore set to 002 and the material number is written into the IDTNR field. E1EDP19 segments are always children of E1EDP01.
If you like, take a look at transaction WE60 to search for the segment documentation of IDoc type ORDERS01.