SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → Simple Transformations → ST - Addressing ABAP Data →ST - tt:ref, Current Node
Syntax
... [tt:]ref ...
Effect
Exactly one node of the tree structures of the current template can be set as the current node at any place within a Simple Transformation (statically and during program execution). The current node shades the data roots in the sense that a reference name does not refer to a root name, but to the component name of the current node (see Addressing Subnodes). If the current node is defined, it is the implicit operand of many ST commands, but you can also address it explicitly using $ref.
This section shows how you can set the current node explicitly with [tt:]ref. In addition, the tt:loop statement for transforming internal tables also sets the current node.
At positions where the current node is not set explicitly, it is undefined and cannot be addressed using $ref. At these positions, the data roots are not shaded and you can address them with name.
Use a command to set the current node
The tt:ref command sets the current node to the node specified in node. Any addressable data node can be specified for node. If no valid node is specified, the current node is undefined.
The tt:ref command can be nested. It builds a context in which the currently set node is valid. Outside the corresponding XML element, the current outermost node is still valid. On the top level, the current node is always undefined.
The tt:ref command itself has no operational effect; it only influences the impact of the commands nested within it.
Note
As a result of the addressing rules, only a subnode of the current node can be set as the new current node, unless you are setting a data root.
Use an attribute to set the current node
Many ST commands allow you to specify the current node as the content of the attribute ref. The same rules apply to node as when you set it with the tt:ref command. If no attribute ref is specified, the command applies to the current node of the context. The currently set node is valid only within the context of the ST command.
Set the current node in literal XML elements
In a literal XML element, tt:ref is a special attribute in the namespace of the ST command and sets the current node there. The same rules apply to node as when you set it with the tt:ref command. The currently set node is valid only within the context of the XML element.
Example
The following ST program can be used to serialize a nested ABAP structure:
The current node is changed as follows:
Also see the example for calling a transformation in the tt:value, Structures section.