ABAP Keyword Documentation → ABAP - Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → ST - Simple Transformations → ST - Modularization with Subtemplates
ST - tt:template, tt:context, Create Subtemplate
Other versions: 7.31 | 7.40 | 7.54
Syntax
<tt:template name="tmpl">
[<tt:context>
[<tt:root name="root1" [[line-]type=...] />
<tt:root name="root2" [[line-]type=...] />
...]
[<tt:parameter name="para1" [[s-|d-]val="def1"]
[kind="knd1"] />
<tt:parameter name="para2" [[s-|d-]val="def2"]
[kind="knd2"] />
...]
[<tt:variable name="vari1" [[s-|d-]val="val1"] />
<tt:variable name="vari2" [[s-|d-]val="val2"] />
...]
</tt:context>]
...
</tt:template>
Effect
Like the main template, subtemplates are defined with tt:template. Using the attribute name, define a unique name tmpl for the subtemplate.
Data in Subtemplates
In a subtemplate, you can optionally declare your own data: Use tt:context to define a context for tt:root, tt:variable, and tt:parameter commands. The tt:context command is allowed only in subtemplates and the tt:root, tt:variable, and tt:parameter commands are allowed in a template only within tt:context.
As for the main template, there are three kinds of data that all lie in one namespace:
- Data Roots
- Parameters
- Variables
Addressing Data in Subtemplates
A subtemplate without separate data roots creates a separate tree structure of data nodes whose root node is the current node from the calling position in the calling template. As a prerequisite for calling such a template, the current node must be defined at the call position. At the start of the subtemplate, this root node is also the current node of the subtemplate. In such a subtemplate, the current node can be set as described for main templates, but in contrast to main templates, it is never undefined. Data nodes outside of the tree structure of the subtemplate cannot be addressed. In particular, the data roots of the main template cannot be addressed with .name.
Addressing the data nodes of a subtemplate with own data roots happens exactly as described for the main template. As long as no current node is defined, you can address the data roots of the subtemplate with name. After they are shaded by a current node, the only way to address them is with .name.
Note
Figuratively speaking, a subtemplate without separate data roots works exclusively with the substructure of the main template tree structure whose root nodes are bound.
Examples
See Call Subtemplate.