Start of Content Area

Object documentation Data Roots  Locate the document in its SAP Library structure

To be able to access ABAP data, an ST program must contain at least one declaration of a data root outside a template. The data roots are the interfaces of the ST program to the ABAP data objects, which you specify in the statement CALL TRANSFORMATION as source or target fields. You declare data roots with:

 

<tt:root name="..." [[line-]type="..." [length="..."] [decimals="..."]] [...] />

 

A name has to be assigned to the data root using attribute name. It can be typed using attribute [line-]type.

The data roots declared on the tt:transformation level form the context of the main template and can be addressed directly within it. The data roots are not known in subtemplates. However, they can be bound to the local data roots of subtemplates when these templates are called.

 

Note

An ST program without a data root describes a constant XML fragment that does not access ABAP data. In the CALL TRANSFORMATION statement, the syntax requires you to specify source or target fields. Data objects specified in the call of ST programs without data roots are ignored during serialization and not changed during deserialization. The example for literal texts uses ST programs without data roots.

 

Data Root Name

Use the name attribute to declare a symbolic name, which can be bound to an ABAP data object. This binding is achieved by assigning these names as bni to data object ei during serialization or to fi during deserialization in the CALL TRANSFORMATION statement (see ABAP keyword documentation).

The symbolic name is not case-sensitive and must be unique. The namespace also includes the parameters declared with tt:parameter and the variables declared with tt:variable. No data roots other than the one specified here can be used in the CALL TRANSFORMATION statement.

 

Typing the Data Root

The data root can be typed with a data type using attribute type or line-type of tt:root. Whereas type directly specifies the type, line-type means that it is an internal table of the named type.

For data roots without explicit typing, no checks are made until the transformation is executed. With explicit typing, this is used to statically check the ST program. Examples of invalid operations that can then be recognized by the compiler are:

     Access to a non-existing structure component

     Loop through a non-tabular node

     Handling a structured node as elementary

Elementary ABAP types, types from the Repository and types of the same ST program that are defined with tt:type can be specified as the value of [line-]type. For the type specification, the same applies as with the tt:value statement.

 

Example

Six data roots including typing are defined in the following transformation. Data root R1 has elementary ABAP type d (date), R2 has type "internal table with elementary line type i", R3 has type DSTRUCT from the ABAP Dictionary, R4 has the type ABCD_STRUCT from type group ABCD, and R5 is a table with type ABCSTRUCT that is defined in global class CL_ABC. The type of R6 is defined as the name STRUCT in the transformation itself.

...

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates"
              xmlns:ddic="http://www.sap.com/abapxml/types/dictionary"
              xmlns:tp="http://www.sap.com/abapxml/types/type-pool/ABCD"
              xmlns:cl="http://www.sap.com/abapxml/types/class-pool/CL_ABC"

              xmlns:def="http://www.sap.com/abapxml/types/defined" >

  <tt:type name="STRUCT">
    <tt:node name="C1" type="I"/>
    <tt:node name="C2" type="I"/>
  </tt:type>

  <tt:root name="R1" type="D"/>
  <tt:root name="R2" line-type="I"/>
  <tt:root name="R3" type="ddic:DSTRUCT"/>
  <tt:root name="R4" type="tp:ABCDSTRUCT"/>
  <tt:root name="R5" line-type="cl:ABCSTRUCT"/>
  <tt:root name="R6" type="def:STRUCT"/>

...

 

 

 

End of Content Area