Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

parameter use in simple transformation

former_member413266
Discoverer
0 Likes
2,066

Hi all,

I would like change the following simple transformation such that the underlined area is dynamic:

<?sap.transform simple?>

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

  <tt:root name="JS_COMMAND_ID"/>

  <tt:template>

    <Jetstream xmlns=http://Jetstream.TersoSolutions.com/v1.0/CommandResponse>


I have created a parameter that I am able to successfully pass into the transformation:

<tt:parameter name="VERS" kind="in" type="STRING"/>

I can see that this parameter contains the correct value in the debugger.  However, when I try to use it as so:

<Jetstream xmlns="VERS">

I receive an element mismatch error.  I have also tried "$VERS" with no success either.

Any suggestions?

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,332

Did you try <Jetstream><tt:attribute name="xmlns" value-ref="VERS"/> ?

Did you try <Jetstream><tt:attribute name="xmlns" value-ref="VERS"/> ?

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,333

Did you try <Jetstream><tt:attribute name="xmlns" value-ref="VERS"/> ?

Read only

0 Likes
1,332


Sandra,

Thanks for your suggestion, however that approach results in an 'unknown root VERS' syntax error.  I am now trying this:

While this passes syntax checking, I receive a "Error during access to the ref node "JSVERNUM'. The ref node is not defined or does not have the necessary type' error upon execution.  (I realize I have a redundant variable in there, but when I try using the variable directly I get an 'unknown ROOT' message.)  As mentioned previously, the value of the input parameter is correct, and I can see that the value of the variable is being assigned correctly.  Now it insists that I use a ROOT defined variable in the tt:attribute statement, but flags an error if I try to set the value of this data ROOT.

Read only

0 Likes
1,332

Indeed, it seems the only solution is to define it as a root. Is that a problem?

This code works:

  DATA xml_string TYPE string.
  CALL TRANSFORMATION ztest
        SOURCE  var_xmlns = 'urn:test'
        RESULT  XML  xml_string.

The transformation :

<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="VAR_XMLNS"/>
<tt:template>
  <Jetstream>
   <tt:attribute name="xmlns" value-ref="VAR_XMLNS"/>
value
</Jetsream>
</tt:template>
</tt:transform>

The result (in xml_string) :

<?xml version="1.0" encoding="utf-16"?>
<Jetstream xmlns="urn:test">##  value##  </Jetstream>