ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → ST - 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
In deserializations, variable inbound XML streams containing groups of related elements in any order can be responded to using the statement tt:group. Hereby, a list of cases is specified in tt:group, where the syntax of each case is formulated by a conditional transformation, namely 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, the following must be noted:
- Any number of serialization-relevant cases can be specified in which no attribute using, data, or check is specified.
- Only one deserialization-relevant case that does not contain a pattern can be specified. This case is called standard deserialization.
To control how often a deserialization-relevant case must or can be executed in deserializations, 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 inbound XML 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 in serializations).
- frq="?" is used implicitly in tt:cond cases that contain a data condition (that need not be executed in serializations).
Serialization
In serializations, the element tt:group is executed once as follows: All serialization-relevant cases with a met prerequisite or no prerequisite using, data, or check are executed in the given order.
Deserialization
In deserializations, 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 inbound XML 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: