Problem solve Get help with specific problems with your technologies, process and projects.

Learn how to copy IDoc data into a CSV data

Learn how to copy IDoc data into a CSV data with this description and sample code from Axel Angeli.

In SE80 I created an ABAP class. My piece of OO ABAP code has loaded in an inbound IDoc (eg. HRMD_A06)into the parser (DOM). Now, I want to loop through the parser document sequentially to locate specific data (eg. Segments E1P1000 and E1P1001) and load this data (eg. append) into defined/declared internal tables for further processing (I want to then render out a result in a CSV file).

Can you provide me with a sample of OO ABAP code for looping through a parser document and storing the infotype field data into internal tables? I'd also like code for the rendering of data into a CSV file.

I think there is a mix and match of terminology. When you speak of a parser, do you have an XML document? An IDoc is simple flat table that is delivered to you as internal table. The internal table has the structure EDIDD (like: DATA: INT_EDIDD type table of EDIDD). The following code copies IDoc data into a CSV data:
data: int_edidd type table of edidd with header line.
Data: csvtab type table of string.
Field-symbols: &ltsdata> type any.
Field-symbols: &ltfld> type any.
Data: comps type I, typ type C.
Data: sep type c.
Data: str type string.

Loop at int_edidd.
  Assign int_edidd-sdata to &ltsdata> casting type (int_edidd-segnam).
  Sep = space.
  Describe field &ltsdata> type typ components comps.
Do comps times.
 Assign component sy-index of structure &ltsdata> to &ltfld>.
 Concatenate str &ltfld> into str.
Append str to csvtab.


Dig Deeper on SAP integration