Skip to content

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:cond, Conditional Transformations 

ST - check, Conditions

Other versions: 7.31 | 7.40 | 7.54

Syntax


... [s-|d-]check ="..." ...

Effect

The following conditions can be specified for the content of the attribute [s-|d-]check of an element tt:cond or tt:cond-var:

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.

  • Variables are specified in the form var(variable), where variable is a variable or a parameter.

Data nodes cannot be specified as operands if check is specified as an attribute of tt:cond-var.

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 less than that of the right operand.
<= Met if the value of the left operand is less than or equal to that of the right operand.


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;.

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 not both cond1 and cond2 are not met.

Conditions can be enclosed in parentheses ( ) to change the priority.


Example

The element X is respected in serializations only if the ABAP data object bound to ROOT is not initial.

<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>


Example

The element X is respected in serializations only if the ABAP data object bound to ROOT1 is less than or equal to the value of the ABAP data object bound to ROOT2. It should be noted that the data root .ROOT2 cannot be specified directly in the condition and that ref('.ROOT2') must be used instead.

<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>


Example

The element X is respected in serializations only if the ABAP data object bound to ROOT1 is between the values of the ABAP data objects bound to ROOT2 and ROOT3. The data roots ROOT2 and ROOT3 cannot be specified directly in the condition and ref('.ROOT2') and ref('.ROOT3') must be used instead.

<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>