Show TOC

Syntax documentationAddressing the Current Node Locate this document in the navigation structure

In all ST commands 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 specification of the node is optional, ST commands use the current node by default.

Note

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

Example

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

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:root name="ROOT"/>
  3.   <tt:template>
  4.     <X tt:ref="ROOT">
  5.       <X1 tt:ref="$ref.COL1">
  6.         <tt:value ref="$ref" />
  7.       </X1>
  8.       <X2 tt:ref="$ref.COL2">
  9.         <tt:value ref="$ref" />
  10.       </X2>
  11.       <X3 tt:ref="STRUC2">
  12.         <X1 tt:ref="COL1">
  13.           <tt:value />
  14.         </X1>
  15.         <X2 tt:ref="COL2">
  16.           <tt:value />
  17.         </X2>
  18.       </X3>
  19.     </X>
  20.   </tt:template>
  21. </tt:transform>
  22.  
End of the code.

In the example, subnodes COL1 and COL2 are set as the current node in the surrounding elements of the tt:value commands 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 commands, while specification is implicit in the other two tt:value commands.

Also see the example for calling a transformation in the Structures section.