Start of Content Area

Syntax documentation Defining Subtemplates  Locate the document in its SAP Library structure

Like the main template, subtemplates are defined with tt:template.

 

<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>

 

Under name, define a unique name tmpl for the subtemplate.

 

Data in Subtemplates

In a subtemplate, you can optionally declare own data: Use tt:context to define a context for tt:root, tt:variable and tt:parameter commands. The command tt:context is allowed only in subtemplates and the commands tt:root, tt:variable and tt:parameter 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

The data roots declared with tt:root have the same meaning for the subtemplate as have the data roots declared on the highest hierarchy level for the main template: They also spread independent tree structures. In contrast to the data roots of the main template, the local data roots of subtemplates do not form a simple transformation interface to the ABAP program, but instead an interface to the including template, to which an ABAP data object can be bound with tt:with-root.

The data roots of the subtemplates can be typed in exactly the same way as the main templates using attribute [line-]type.

·        Parameters

The parameters declared with tt:parameter are formal parameters of the subtemplate, to which you can pass a value using tt:with-parameter. Otherwise, the same applies as for the parameters of the main template.

·        Variables

The variables declared with tt:variable are local variables of the subtemplate; they are visible only there. Otherwise, the same applies as for the variables of the main template.

 

Note

Local types cannot be defined in subtemplates using tt:type.

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.

 

 

 

 

End of Content Area