Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Transformation from ABAP to XML and back

Former Member
0 Kudos

Hi experts,

Can anyone provide me a simple example of a 'simple transformation' that will convert and internal table with more than one column into XML via a simple transformation.

I've spend days now reading SAP help and e-learning examples, but this just won't work and I am getting short dumps saying 'The goal was to access variable "ROOT". However, this access was notv possible.'

Here is my ABAP:

data: begin of struc,
           counter type i,
           aname type string,
           aname2 type string,
      end of struc.
data: cnt_c type c.
data: itab like table of struc with HEADER LINE,
      xml_string type xstring.
do 3 times.
     move sy-index to: itab-counter, cnt_c.
     concatenate 'nameA' cnt_c into itab-aname.
     concatenate 'nameB' cnt_c into itab-aname2.
     append itab.
enddo.
CALL TRANSFORMATION Z_ST_TEST5
       SOURCE  ROOT = itab
       RESULT XML xml_string.
CALL FUNCTION 'DISPLAY_XML_STRING'
  EXPORTING
    XML_STRING            = xml_string.
skip 1.

and here is my ST:

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
    <tt:template>
     <TABLE>
      <tt:loop ref=".ROOT" name="line">
        <ITEM>
          <counter>
            <tt:value ref="$line.aname" />
          </counter>
          <name>
            <tt:value ref="$line.aname" />
          </name>
          <name2>
            <tt:value ref="$line.aname2" />
          </name2>
        </ITEM>
      </tt:loop>
     </TABLE>
    </tt:template>
</tt:transform>

1 REPLY 1

Former Member
0 Kudos

Figured it out. The interla tables used in teh call transformation statement can never have a header line.