In this recipe, we will see how we can create transformations for internal tables. We will use the transformation editor to define the transformation for the internal table, ITAB
, comprising of two fields, FIELD1
and FIELD2
.
We will now see the steps for creating a transformation corresponding to internal tables:
zst6_internal_table
.itab
with fields field1
and field2
and fill it with the necessary data.CALL TRANSFORMATION
statement is called, the internal table is passed, and the result is stored in xml_string
.The transformation contains a root element representing the internal table by the name of ITAB
. Within the template, the XML literal element, itab
, is defined to show the contents of the internal table. The tt:loop
command is included. This command addresses each line of the table itab
(since ref=".ITAB"
is used as the current node). For each record of the table, the content of the XML element line
is included in the XML file. Within the XML elements FIELD1
and FIELD2
, the contents of the FIELD1
and FIELD2
fields of the relevant line of the table itab
is written. Since the current node is the row of the internal table in question, including FIELD1
and FIELD2
it will print the right contents.
We create the program and pass the necessary data for itab
. After the serialization, the resulting XML file appears as shown in the following screenshot:
52.15.42.128