SAP ST TT SWITCH
Get Example source ABAP code based on a different SAP table
ARTICLE
Syntax
<(><<)>tt:[s-|d-]cond ...
<(><<)>tt:[s-|d-]cond ...
...
<(><<)>/tt:switch>
Effect
To execute only one transformation from a set of conditional transformations, you can use the statement
In contrast to conditional transformations positioned outside of
In the list of cases, you must note the following:
Serialization
Serialization follows these rules: The first serialization-relevant case
For a successful serialization, exactly one case is executed.
Deserialization
Deserialization follows these rules: The first deserialization-relevant case
For a successful deserialization, exactly one case is executed.
Note
When programming case distinctions, you should formulate serialization and deserialization as much as possible in common cases
Example
The transformation below during serialization sets the attribute
xmlns:tt='http://www.sap.com/transformation-templates'>
<(><<)>tt:root name='SIZE'/>
<(><<)>tt:template>
<(><<)>Paragraph>
<(><<)>tt:attribute name='size'>
<(><<)>tt:switch>
<(><<)>tt:s-cond check='SIZE<(><<)>10'>
<(><<)>tt:text>Small<(><<)>/tt:text>
<(><<)>/tt:s-cond>
<(><<)>tt:s-cond check='SIZE>20'>
<(><<)>tt:text>Big<(><<)>/tt:text>
<(><<)>/tt:s-cond>
<(><<)>tt:s-cond>
<(><<)>tt:text>Medium<(><<)>/tt:text>
<(><<)>/tt:s-cond>
<(><<)>tt:d-cond using='exist(SIZE)' data='SIZE=8'>
<(><<)>tt:text>Small<(><<)>/tt:text>
<(><<)>/tt:d-cond>
<(><<)>tt:d-cond using='exist(SIZE)' data='SIZE=16'>
<(><<)>tt:text>Medium<(><<)>/tt:text>
<(><<)>/tt:d-cond>
<(><<)>tt:d-cond using='exist(SIZE)' data='SIZE=28'>
<(><<)>tt:text>Big<(><<)>/tt:text>
<(><<)>/tt:d-cond>
<(><<)>tt:d-cond using='exist(SIZE)' data='SIZE=12'>
<(><<)>tt:skip/>
<(><<)>/tt:d-cond>
<(><<)>/tt:switch>
<(><<)>/tt:attribute>
<(><<)>tt:text>Text<(><<)>/tt:text>
<(><<)>/Paragraph>
<(><<)>/tt:template>
<(><<)>/tt:transform>
If, for example, the input values for
During deserialization,
In the above transformation, serialization and deserialization are treated completely separately; they are divided within one single
xmlns:tt='http://www.sap.com/transformation-templates'>
<(><<)>tt:root name='SIZE'/>
<(><<)>tt:template>
<(><<)>Paragraph>
<(><<)>tt:attribute name='size'>
<(><<)>tt:serialize>
<(><<)>tt:switch>
<(><<)>tt:cond check='SIZE<(><<)>10'>
<(><<)>tt:text>Small<(><<)>/tt:text>
<(><<)>/tt:cond>
<(><<)>tt:cond check='SIZE>20'>
<(><<)>tt:text>Big<(><<)>/tt:text>
<(><<)>/tt:cond>
<(><<)>tt:cond>
<(><<)>tt:text>Medium<(><<)>/tt:text>
<(><<)>/tt:cond>
<(><<)>/tt:switch>
<(><<)>/tt:serialize>
<(><<)>tt:deserialize>
<(><<)>tt:cond using='exist(SIZE)'>
<(><<)>tt:switch>
<(><<)>tt:cond data='SIZE=8'>
<(><<)>tt:text>Small<(><<)>/tt:text>
<(><<)>/tt:cond>
<(><<)>tt:cond data='SIZE=16'>
<(><<)>tt:text>Medium<(><<)>/tt:text>
<(><<)>/tt:cond>
<(><<)>tt:cond data='SIZE=28'>
<(><<)>tt:text>Big<(><<)>/tt:text>
<(><<)>/tt:cond>
<(><<)>tt:cond data='SIZE=12'>
<(><<)>tt:skip/>
<(><<)>/tt:cond>
<(><<)>/tt:switch>
<(><<)>/tt:cond>
<(><<)>/tt:deserialize>
<(><<)>/tt:attribute>
<(><<)>tt:text>Blahblah<(><<)>/tt:text>
<(><<)>/Paragraph>
<(><<)>/tt:template>
<(><<)>/tt:transform>