Basically an IDOC is formed of segments, and comprises of IDOC Type and IDOC Data. IDOC types defines the structure and format of the data being exchanged. You can see in the figure below how an IDOC is represented in the SAP system. Please note that when you are looking at an IDOC of Sales Order, the generated IDOC will have all the data stored in the Sales Order, also there are means of filtering out the data that you do not want to include in the IDOC or you can also include some addition data. The actual Sales Order will be saved in the tables associated with Sales Order example VBAK, VBAP etc. Where as the generated IDOC will be stored separately.
Typically an IDOC will have the following
Control Record
Data Records
Status Records
Please see the figure given below.
Control Record:
Will have all the following.
IDOC number
IDOC TYPE
Sender and Receiver Information
Message Type
Please note that there is only one control record per IDOC and the structure of IDOC control record is the same for all IDOCs.
Data Record:
This basically contains the data, the header data and the line item data for a particular IDOC for example Sales Order or Purchase Order. These are multiple records.
Status Record:
This represents the different status the IDOC goes through. And a status record will have multiple statuses. A status code, Date and Time are assigned.
Always use Pretty Printer and Extended Program Check before releasing the code.
Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive.