ABAP Keyword Documentation → ABAP - Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Simple Transformations → ST - Serialization and Deserialization → ST - Flow Control
ST - tt:group, Grouping
Other versions: 7.31 | 7.40 | 7.54
Syntax
<tt:group>
<tt:[s-|d-]cond [frq="..."] ...
<tt:[s-|d-]cond [frq="..."] ...
...
</tt:group>
Effect
During deserialization, you can react to variable XML inbound streams containing groups of related elements in any sequence by using the statement tt:group. Hereby, a list of cases is specified in tt:group, where each case is syntactically formulated by a conditional transformation, that is, a subelement tt:[s-|d-]cond. In this case, tt:[s-]cond defines a serialization-relevant case, and tt:[d-]cond a deserialization-relevant case. Other direct subelements are not possible in tt:group. The statement tt:group can be a subelement of tt:[s-|d-]cond.
In contrast to conditional transformations positioned outside of tt:group, there is no need to specify at least one attribute using, data or check for a case, provided that the content of tt:[s-|d-]cond is not a pattern.
In the list of cases, you must note the following:
- You may specify any number of serialization-relevant cases, in which no attribute using, data, or check is specified.
- You may specify only one deserialization-relevant case that does not contain a pattern. This case is called standard deserialization.
To control how often a deserialization-relevant case must or can be executed during deserialization, tt:[d-]cond within tt:group can contain the additional attribute frq (frequency) with one of three allowed values:
- </tt:[d-]cond ... frq="1" >
- </tt:[d-]cond ... frq="?" >
- </tt:[d-]cond ... frq="*" >
For frq="?" and frq="*", the expected element must not necessarily exist in the XML inbound stream.
Implicit frequency: If the attribute frq is not specified explicitly,
- frq="1" is used implicitly in tt:cond cases that do not contain data conditions (that must be executed during serialization).
- frq="?" is used implicitly in tt:cond cases that contain a data condition (that need not be executed during serialization).
Serialization
During serialization, the element tt:group is executed once as follows: All serialization-relevant cases with fulfilled prerequisite or no prerequisite using, data, or check are executed in the given order.
Deserialization
During deserialization, the element tt:group initiates a loop. The system tries to select every required case (frequency 1) once. As soon as this happens, the loop ends. Until then, optional cases (frequency ?, up to once) and multiple cases (frequency *, also multiple) can also be selected. In every loop pass, one of the deserialization-relevant cases whose maximum case frequency has not yet been reached is selected as follows:
Example
The following transformation shows how groupings work:
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT1"/>
<tt:root name="ROOT2"/>
<tt:root name="ROOT3"/>
<tt:root name="ROOT4"/>
<tt:template>
<X0>
<tt:group>
<tt:cond>
<X3>
<tt:value ref="ROOT3"/>
</X3>
</tt:cond>
<tt:cond frq="?">
<X2>
<tt:value ref="ROOT2"/>
</X2>
</tt:cond>
<tt:cond frq="*">
<X1>
<tt:value ref="ROOT1"/>
</X1>
</tt:cond>
<tt:cond>
<tt:skip count="1"/>
</tt:cond>
</tt:group>
<X4>
<tt:value ref="ROOT4"/>
</X4>
</X0>
</tt:template>
</tt:transform>
Assume that an XML inbound stream has the following form:
<X1>1</X1>
<X1>2</X1>
<X2>3</X2>
<X2>4</X2>
<X3>5</X3>
<X4>6</X4>
</X0>
The deserialization proceeds as follows: