Conditions 
For the content cond of the attribute [s-|d-]check of an element tt:cond or tt:cond-var, you can specify the following conditions. The operands of the conditions can be either data nodes (not in tt:cond-var), variables, or values.
Data nodes are specified in the form dnode.
You specify variables in the form
var(variable)
You specify values in the form
value
where value is a value specified according to the rules for ABAP values.
Note
If check is specified as an attribute of tt:cond-var, you cannot specify data nodes as operands.
Note
In tt:cond-var, the state query exist is not possible.
The element X is taken into account during serialization only if the ABAP data object bound to ROOT is not initial.
Syntax
<tt:transform 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>
Comparisons are specified in the form:
dnode|var(variable)| value dnodeoperator|var(variable)|value
The following operators are possible:
Relational operator |
Meaning |
= |
The condition is met if both operands have the same value. |
!= |
The condition is met if both operands do not have the same value. |
>, > |
The condition is met if the value of the left operand is greater than that of the right operand. |
>=, >= |
The condition is met if the value of the left operand is greater than or equal to the value of the right operand. |
< |
The condition is met if the value of the left operand is smaller than that of the right operand. |
<= |
The condition is met if the value of the left operand is smaller than or equal to the value 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 >.
The element X is taken into account during serialization only if the value of the ABAP data object bound to ROOT1 is smaller than or equal to the value of the ABAP data object bound to ROOT2.
Syntax
<tt:transform 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>
Note that you cannot directly specify the data root .ROOT2 in the condition; you must use ref('.ROOT2') instead.
Conditions 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.
The element X is taken into account during serialization only if the value of the ABAP data object bound to ROOT1 is between the values of the ABAP data objects bound to ROOT2 and ROOT3.
Syntax
<tt:transform 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>
Note that you cannot directly specify the data roots .ROOT2 and .ROOT3 in the condition; you must use ref('.ROOT2') and ref('.ROOT3') instead.