Skip to Content
0
May 11, 2016 at 03:57 PM

Dynamically transform any data objects from ABAP to XML.

1939 Views

Hey, we are currently working on an ICF Service, which calls some function modules.

The result of those calls (i.e. any export parameter) will be converted to an XML.

Unfortunately, the development of the function module is beyond our control. Therefore we do not know the type of the individual parameters.

Our goal is the following XML structure:

Any simple type is mapped to a single XML tag.

Example:

e_result TYPE string VALUE 'hello'.

will be mapped to:

<E_RESULT>hello<E_RESULT>

Structures are mapped as following (the given structure type will be in data dictionary, as it is used as export parameter):

BEGIN OF my_ddic_str

result TYPE string

result2 TYPE i

END OF my_ddic_str.

DATA bla TYPE my_ddic_str.

my_ddic_str-result = 'hello'.

my_ddic_str-result = 'hello2'.

will be mapped to:

<BLA result="hello" result2="hello2"/>

If any component of the structure is deep, it will be added as child tag.

Example:

BEGIN OF internal_str

result2 TYPE string

result3 TYPE string

END OF internal_str

BEGIN OF my_ddic_str

result TYPE string

internal TYPE internal_str

END OF my_ddic_str.

DATA bla TYPE my_ddic_str.

my_ddic_str-result = 'hello'.

DATA bla2 TYPE internal_str

bla2-result2 = 'hello2'.

bla2-result3 = 'hello3'.

will be mapped to:

<BLA result="hello">

<INTERNAL result2="hello2" result3="hello3"/>

</BLA>

Any table is mapped to a main table tag, whose lines are children tags. Those children tags have "item" as name and look the same, as the structure tags (as table lines are structures).

Is there any way in XSLT or ST (Simple Transformation) to detect the type of the given data, so that we can build the XML, based on that type?
Unfortunately the identity transformation does not fit our needs, as it does not add structure's components as attributes.

Kind regards

Tobias