An common case is, that the IDoc is given as a file. In this case,you have two possibilities for reading the IDoc:
Using the FlatFile Adapter is helpful, if you need to process the IDoc to SAP tables afterwards, e.g. for calling a SAP RFC adapter.
It is very convenient that the Builder provides ready structured IDoc_FlatFile classes. One class IDOC_FlatFile to be used for files containing only one IDoc, one class IDOCs_FlatFile to be used for files containing multiple IDocs.
If the IDoc file contains only a single IDoc, you can easily read the file as shown in the example below.
Figure: Read IDoc File To IDoc_FlatFile Object
After having read the IDoc file, move the IDoc_FlatFile object to a (SAP) Tables object as shown above.
If the IDoc file contains multiple IDocs,it is a bit more complicated to create the SAP tables. This is because of the different data structure of the flat file and the SAP tables.
Figure: Overview on the Differences Between the Structure of IDOc FlatFiles and SAP Tables
If the IDoc file does not contain the IDoc data according to the structure above but in a different order, it is not possible to use the FlatFile Adapter to read the IDoc file. |
Find below an example of reading an IDoc flat file and creating the SAP tables.
In all other cases (e.g. if you need to parse the IDoc to a specific structure), it is more convenient to use the File System Adapter to read the IDoc file.
Figure: Read IDoc File with File System Adapter