ABAP - Keyword Documentation →  ABAP - Programming Language →  Data Interfaces and Communication Interfaces →  ABAP and XML →  XML - Transformations →  Simple Transformations (ST) →  ST - Addressing ABAP Data →  ST - Addressing Data Nodes → 
Mail Feedback

ST - Addressing the Current Node

In all ST statements in which the name of a node can be specified, the current node can be addressed explicitly with $ref. An alias name can be also be defined for $ref in tt:loop loops where internal tables are transformed. If specifying the node is optional, ST statements use the current node by default.

Hint

If the current node is undefined, it cannot be addressed using $ref and ST statements that work implicitly with the current node cannot be executed.

Example

The following ST program DEMO_ST_CURRENT_NODE can be used to serialize a nested ABAP structure:

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:template>
    <X tt:ref="ROOT">
      <X1 tt:ref="$ref.COL1">
        <tt:value ref="$ref"/>
      </X1>
      <X2 tt:ref="$ref.COL2">
        <tt:value ref="$ref"/>
      </X2>
      <X3 tt:ref="STRUC2">
        <X1 tt:ref="COL1">
          <tt:value/>
        </X1>
        <X2 tt:ref="COL2">
          <tt:value/>
        </X2>
      </X3>
    </X>
  </tt:template>
</tt:transform>

In this example, subnodes COL1 and COL2 are set as the current node in the surrounding elements of the tt:value statements with ROOT and STRUC2, respectively. In the first two elements, the current node is addressed explicitly using $ref for demonstration purposes. The current node is also specified using $ref in the first two tt:value statements, while specification is implicit in the other two tt:value statements.

Also see the example for calling a transformation in the tt:value, Structures section.