Show TOC

Syntax documentationConditions for Variables Locate this document in the navigation structure

The statement tt:cond-var allows conditional transformations for which, unlike tt:[s-ld-]cond, only data content can be specified and not conditions for the data flow:

Syntax Syntax

  1. <tt:cond-var check="cond">
  2.    ... 
  3. </tt:cond-var>
End of the code.

The content of tt:cond-var is processed depending on a condition cond. The same applies to cond as to general conditions, with the exception that you can only specify variables and values as operands, but no data nodes.

Outside of tt:switch-var, you must specify a condition check.

Serialization and Deserialization

During serialization and deserialization, the condition is checked and the content of the element tt:cond-var is only processed if the condition is met.

Note Note

Unlike general conditional transformations with tt:[s-|d-]cond, the content of the XML input stream for tt:cond-var is irrelevant.

End of the note.
Example

The following transformation demonstrates a condition for a parameter:

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:root name="ROOT"/>
  3.   <tt:template>
  4.     <tt:apply name="SUB">
  5.       <tt:with-parameter name="PARA" ref="ROOT"/>
  6.     </tt:apply>
  7.   </tt:template>
  8.   <tt:template name="SUB">
  9.     <tt:context>
  10.       <tt:parameter name="PARA"/>
  11.     </tt:context>
  12.     <tt:cond-var check="PARA<100">
  13.       <X val="small">...</X>
  14.     </tt:cond-var>
  15.     <tt:cond-var check="PARA>=100">
  16.       <X val="big">...</X>
  17.     </tt:cond-var>
  18.   </tt:template>
  19. </tt:transform>
End of the code.

In tt:apply, the value of the data root ROOT is passed to the parameter PARA of the subtemplate SUB and checked there. Depending on whether the ABAP data object bound to ROOT is smaller, greater than, or equal to 100, the serialization generates either of the following:

<X val="small">...</X>

or

<X val="big">...</X>

In the check conditions, you could also write var(PARA) instead of PARA.