ABAP Keyword Documentation → ABAP - Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Simple Transformations → ST - Serialization and Deserialization → ST - Flow Control → ST - tt:cond, Conditional Transformations
ST - check, Conditions
Other versions: 7.31 | 7.40 | 7.54
Syntax
... [s-|d-]check ="..." ...
Effect
For the content of the attribute [s-|d-]check of an element tt:cond or tt:cond-var, you can specify the following conditions:
State Queries
Condition | Meaning |
---|---|
exist(node) | Met if an ABAP data object is bound to the node. |
[not-]initial(node) | Met if the bound ABAP data object is (not) initial. |
[not-]initial(var(variable)) | Met if the variable is (not) initial. |
The operands of the conditions can be data nodes, variables, or values.
- Data nodes node are specified in a special form.
- Values value are ABAP values in the associated display format.
If check is specified as an attribute of tt:cond-var, you cannot specify data nodes as operands.
Comparisons
Comparisons are specified in the form:
node|var(variable)|value operator node|var(variable)|value
The following operators operator are possible:
operator | Meaning |
---|---|
= | Met if both operands have the same value. |
!= | Met if both operands do not have the same value. |
>, > | Met if the value of the left operand is greater than that of the right operand. |
>=, >= | Met if the value of the left operand is greater than or equal to that of the right operand. |
< | Met if the value of the left operand is smaller than that of the right operand. |
<= | Met if the value of the left operand is smaller than or equal to that of the right operand. |
Note
In XML, the character < must always be represented by <. The character >, on the other hand, can be used directly or represented by >.
Negation, Linking, Parentheses
Conditions cond can be negated using not
and
can be linked using and or or; note that
and creates a stronger link than or. The result of such an operation is another condition.
Operation | Meaning |
---|---|
not(cond) | Met if cond is not met. |
cond1 and cond2 | Met if both cond1 and cond2 are met. |
cond1 or cond2 | Met if both cond1 and cond2 are not met. |
Conditions can be enclosed in parentheses ( ) to change the priority.
Example
The element X is taken into account during serialization only if the ABAP data object bound to ROOT is not initial.
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<tt:s-cond check="not-initial(ROOT)">
<X>
<tt:value ref="ROOT" />
</X>
</tt:s-cond>
</tt:template>
</tt:transform>
Example
The element X is taken into account during serialization only if the ABAP data object bound to ROOT1 is smaller than or equal to the value of the ABAP data object bound to ROOT2. Note that you cannot directly specify the data root .ROOT2 in the condition; you must use ref('.ROOT2') instead.
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT1"/>
<tt:root name="ROOT2"/>
<tt:template>
<tt:ref name="ROOT1">
<tt:s-cond check="$ref <= ref('.ROOT2')">
<X>
<tt:value/>
</X>
</tt:s-cond>
</tt:ref>
</tt:template>
</tt:transform>
Example
The element X is taken into account during serialization only if the ABAP data object bound to ROOT1 is between the values of the ABAP data objects bound to ROOT2 and ROOT3. You cannot directly specify the data roots ROOT2 and ROOT3 in the condition; you must use ref('.ROOT2') and ref('.ROOT3') instead.
xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT1"/>
<tt:root name="ROOT2"/>
<tt:root name="ROOT3"/>
<tt:template>
<tt:ref name="ROOT1">
<tt:s-cond check="($ref > ref('.ROOT2')) and
($ref < ref('.ROOT3'))">
<X>
<tt:value/>
</X>
</tt:s-cond>
</tt:ref>
</tt:template>
</tt:transform>