Start of Content Area

Syntax documentation Conditions  Locate the document in its SAP Library 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.

     Specify variables in the form

var(variable)

where variable is a variable or a parameter.

     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.

 

State Queries

 

Condition

Description

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

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

 

Example

The element X is taken into account during a serialization only if the ABAP data object bound to ROOTis 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>

 

Comparisons

Comparisons are specified in the form:

 

dnode|var(variable)|value operator dnode|var(variable)|value

 

The following operators are possible:

 

Relational operator

Description

=

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

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

 

Example

The element X is taken into account during a 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.

 

<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 &lt;= ref('.ROOT2')">
        <X>
          <tt:value/>
        </X>
      </tt:s-cond>
    </tt:ref>
  </tt:template>

</tt:transform>

 

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

 

Negation, Linking, Brackets

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

Description

not(cond)

Met if cond is not met.

cond1 and cond2

Met if both cond1 and cond2 are met.

cond1 or cond2

Met if either cond1, cond2, or both are met.

 

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

 

Example

The element X is taken into account during a 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 is and ROOT3.

 

<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 &lt; ref('.ROOT3'))">
        <X>
          <tt:value/>
        </X>
      </tt:s-cond>
    </tt:ref>
  </tt:template>

</tt:transform>

 

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

 

 

End of Content Area