2009 Apr 24 11:43 AM
Hi,
I have a simple transformation that works if I serialize table data, but it doesn't work when I wan't to deserialize.
Here is my ABAP program that calls the transformation:
TYPES: BEGIN OF flight,
f_id TYPE p LENGTH 5,
data TYPE c LENGTH 40,
END OF flight,
tt_flight TYPE STANDARD TABLE OF flight
WITH DEFAULT KEY.
DATA: data1 TYPE flight.
DATA: data2 TYPE flight.
DATA: xml_string TYPE string.
DATA: tab_data TYPE tt_flight.
data1-f_id = '00001'.
data1-data = 'before'.
APPEND data1 to tab_data.
data2-f_id = '00002'.
data2-data = 'before'.
APPEND data2 to tab_data.
concatenate '<?xml version="1.0" encoding="iso-8859-2"?><XY><flights>'
'<flight><id>11111</id><data>data1</data></flight>'
'<flight><id>22222</id><data>data2</data></flight>'
'</flights></XY>'
into xml_string.
CALL TRANSFORMATION ...
SOURCE XML xml_string
RESULT root = tab_data.
And the transformation:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp_main">
<tt:root name="ROOT"/>
<tt:template name="temp_main">
<XY>
<flights>
<tt:loop name="line" ref="ROOT">
<flight>
<id>
<tt:value ref="f_id"/>
</id>
<data>
<tt:value ref="data">
</data>
</flight>
</tt:loop>
</flights>
</XY>
</tt:template>
</tt:transform>
It won't update or append the content of the xml to my table.
I would like to read many "<flight><id>.....</id><data>......</data></flight>" lines and write them into the table "tab_data".
Could somebody please help me?
Thanks in advance,
Greg
2009 Jun 15 1:07 PM
Hi Greg,
try to address the root node with a period. Instead of
<tt:loop name="line" ref="ROOT">
use
<tt:loop name="line" ref=".ROOT">
Regards
Stephan
2020 Jun 23 3:57 PM