Show TOC

Syntax documentationConditions Locate this document in the navigation structure

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)

    where variable is a variable or a parameter.

  • You specify values in the form

    value

    where value is a value specified according to the rules for ABAP values.

Note Note

If check is specified as an attribute of tt:cond-var, you cannot specify data nodes as operands.

End of the note.
State Queries

Condition

Meaning

exist(dnode)

Met if an ABAP data object is bound to the node

initial(dnode|var(variable))

Met if the bound ABAP data object is initial

not-initial(dnode|var(variable))

Met if the bound ABAP data object is not initial

Note Note

In tt:cond-var, the state query exist is not possible.

End of the note.
Example

The element X is taken into account during serialization only if the ABAP data object bound to ROOT is not initial.

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:root name="ROOT"/>
  3.   <tt:template>
  4.     <tt:s-cond check="not-initial(ROOT)">
  5.       <X>
  6.         <tt:value ref="ROOT" />
  7.       </X>
  8.     </tt:s-cond>
  9.   </tt:template>
  10. </tt:transform>
End of the code.
Comparisons

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.

>, &gt;

The condition is met if the value of the left operand is greater than that of the right operand.

>=, &gt;=

The condition is met if the value of the left operand is greater than or equal to the value of the right operand.

&lt;

The condition is met if the value of the left operand is smaller than that of the right operand.

&lt;=

The condition is met if the value of the left operand is smaller than or equal to the value of the right operand.

Note Note

In XML, the character < must always be represented by &lt;. The character >, on the other hand, can be used directly or represented by &gt;.

End of the note.
Example

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 Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:root name="ROOT1"/>
  3.   <tt:root name="ROOT2"/>
  4.   <tt:template>
  5.     <tt:ref name="ROOT1">
  6.       <tt:s-cond check="$ref <= ref('.ROOT2')">
  7.         <X>
  8.           <tt:value/>
  9.         </X>
  10.       </tt:s-cond>
  11.     </tt:ref>
  12.   </tt:template>
  13. </tt:transform>
End of the code.

Note that you cannot directly specify the data root .ROOT2 in the condition; you must use ref('.ROOT2') instead.

Negation, Linking, Parentheses

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.

Example

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 Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:root name="ROOT1"/>
  3.   <tt:root name="ROOT2"/>
  4.   <tt:root name="ROOT3"/>
  5.   <tt:template>
  6.     <tt:ref name="ROOT1">
  7.       <tt:s-cond check="($ref > ref('.ROOT2')) and ($ref < ref('.ROOT3'))">
  8.         <X>
  9.           <tt:value/>
  10.         </X>
  11.       </tt:s-cond>
  12.     </tt:ref>
  13.   </tt:template>
  14. </tt:transform>
End of the code.

Note that you cannot directly specify the data roots .ROOT2 and .ROOT3 in the condition; you must use ref('.ROOT2') and ref('.ROOT3') instead.