IDoc

IDoc (for intermediate document) is a standard data structure for electronic data interchange (EDI) between application programs written for the popular SAP business system or between an SAP application and an external program.

Different IDoc types are available to handle different types of messages. For example, the IDoc format ORDERS may be used for purchase orders, and the format MATMAS maybe used for Material Master.

IDoc Structure

The high-level structure of an IDoc file consists of :

  • Control record: It contains information about the IDoc datafile like IDoc number, type of IDoc, message type, the current status, sender, receiver, port of the partner, the release of SAP R/3 which produced the IDoc etc.

  • Data records: It contains the actual data categorized within hierarchical segments. The number and type of segments is mostly fixed for each IDoc type.

  • Status records: It contains information about the various stages the IDoc has passed through. It contains messages like 'IDoc created', 'The recipient exists', 'IDoc was successfully passed to the port', 'Could not book the invoice because..'

IDoc Segments

IDoc segments contain the actual data that is sent or received from a partner. The segments contain fields each of which supports a value (data).

An IDoc segment can contain child segments hence the data is structured hierarchically using segments.

Example: ORDERS01 IDoc format sample has the following segments :

  • EDI_DC40 - IDOC Header Segment

  • E1EDK01 - Overall action taken by the IDoc

  • E1EDK14 - Organizational Header

  • E1EDK03 - Document header date segment

  • E1EDKA1 - Partner Information

  • E1EDK02 - Document header reference data

  • E1EDK17 - Terms of Delivery

  • E1EDP01 - Item General Data

  • E1EDS01 - Summary segment general

IDoc Format

One of the IDoc formats that is typically used is a flatfile format where fields and segments occur at specific positions and are of a fixed length.

Sample IDoc Message :

images/download/attachments/144835971/SampleIDocFile-version-1-modificationdate-1645136164000-api-v2.png

Each IDoc segment will have a number of fields, and child segments. The IDocfile will have each segment name followed by the field values. The field values are determined by their position offset in the segment, along with their field length.

The IDoc message has the first segment “EDI_DC40” which is the control segment and it contains information like IDoc number, type of IDoc, message type, the current status, sender, receiver, etc.

The segments following the control segment are the data segment, which contains the actual data.

images/download/attachments/144835971/SampleIDocFileWithSegmentsAndFields-version-1-modificationdate-1645136176000-api-v2.png