Skip to Content
Jun 16, 2016 at 08:13 PM

Trouble using tt:switch / tt:switch-var in simple transformation


Hello gurus,

We are performing a simple transformation on an XML string we retrieve from an external source. A typical sample XML is as follows...

<VEHICLE ID="2064015">



<DATE>2016-05-13 06:53:10.0</DATE>



<LANDMARK>1707 Pacific Supply Modesto</LANDMARK>






<PARAM name="Name">GPS Antenna</PARAM>

<PARAM name="Status">Connected</PARAM>



The PARAMS tag can have immediate level tags with the "name" attributes "Name" and "Status" that I would like to transform into my ABAP internal table, but it can alternatively have a nested deep structure that I need to ignore if the associated "name" attribute is "bus".


<PARAM name="bus">






<desc>Active Fault</desc>




<desc>Auxiliary Pressure #1-VOLTAGE ABOVE NORMAL, OR SHORTED TO HIGH SOURCE</desc>










The SAP documentation describes the tt:switch and tt:switch-var commands, but the examples are a bit lacking.

I have made several attempts using tt:read, tt:attribute, tt:assign, tt:skip, etc, trying to save the attribute value into a variable for testing, but I am still getting the same rather vague error message, "System expected a value for the type C".

<?sap.transform simple?>

<tt:transform xmlns:tt="">

<tt:root name="ROOT"/>

<tt:root name="ROOTPARAMS"/>

<tt:variable name="PARAMNAME"/>

<tt:template name="ZVM_XML_TO_TAB">


<tt:loop name="vehicle" ref=".ROOT">




<tt:loop name="params" ref="$ref.PARAMS">


<tt:attribute name="name" ref="var(PARAMNAME)"/>


<tt:cond-var check="var(PARAMNAME) = 'Name' or var(PARAMNAME) = 'Status'">

<tt:attribute name="name" value-ref="var(PARAMNAME)"/>

<tt:value ref="$params.VMPARAMVALUE"/>














Can anyone please tell me what I am doing wrong with the tt:switch-var statement and how it should be corrected?

Essentially, I need to loop through the PARAMS tags, keeping any values where the name attribute is "Name" or "Status" and excluding any values where the name attribute is "bus" and its associated deep structure content.