Skip to Content
1
Former Member
Apr 24, 2009 at 10:43 AM

Simple transformation : deserialize

598 Views

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