Start of Content Area

Syntax documentation Conditions for Variables  Locate the document in its SAP Library structure

The statement tt:cond-var enables conditional transformations in which, unlike tt:[s-|d-]cond, you cannot specify conditions for the data flow but only for data contents:

 

<tt:cond-var check="cond">
  ...

</tt:cond-var>

 

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

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

 

Example

The following transformation demonstrates a condition for a parameter:

 

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">

  <tt:root name="ROOT"/>

  <tt:template>
    <tt:apply name="SUB">
      <tt:with-parameter name="PARA" ref="ROOT"/>
    </tt:apply>
  </tt:template>

  <tt:template name="SUB">
    <tt:context>
      <tt:parameter name="PARA"/>
    </tt:context>
    <tt:cond-var check="PARA&lt;100">
      <X val="small">...</X>
    </tt:cond-var>
    <tt:cond-var check="PARA&gt;=100">
      <X val="big">...</X>
    </tt:cond-var>
  </tt:template>

</tt:transform>

 

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 ROOTis smaller, greater than or equal to 100, the serialization generates either of the following:

 

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

 

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

 

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

 

 

End of Content Area