You can send IDocs to SAP with the help of LINQ to SAP. The segments can be used in the SAP context.
To use an IDoc in .NET, drag the IDoc component from the toolbox to the data context. The selection of the IDoc is done in the search dialog.
In the following dialog you can find in the left area the structure of the IDoc. In the lower area the fields are shown of the segment that is selected in the treeview. Uncheck unused fields or rename them. In the upper right corner you will find the class names and the collection names (names are generated automatically). If you like, just rename them.
The checkbox selected can be used to deactivate segments which are not used later in the code. Deactivated segments are shown in italic in the treeview.
The following code shows how to use the generated classes. First an IDoc object is generated (MATMAS05) and the most important header information is filled (e.g. sender and receiver information like RCVPRN or SNDPRN).
Two Segments are created: E1MARAM (Basicdata) and E1MAKTM (Shorttext), filled with the required fields and added to the IDoc. The IDoc is sent with Send().
Click to open C# example.
In the transaction WE02 we can see the incoming IDocs, and if the status is green they are successfully processed.