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

Transformation Attribut name dynamically

Former Member
0 Likes
417

Hello,

I send a table with followings values to the transformation:

COL1          COL2

Param1          Value1

Param2          Value2

My XML should look like this:


<MatClassParams Param1="Value1" Param2="Value2"/>


But the XML looks like this:


<MatClassParams $REF.COL1="EPI" $REF.COL1="CMOS"/>


The Transformation looks like this:


    <MatClassParams>

     <tt:loop ref=".PARA.MATCLASSPARAM.MATCLASSPARAM">
       <tt:attribute name="$REF.COL1" value-ref="$REF.COL2"/>
     </tt:loop>
     </MatClassParams>


Can anybody help me?


Ulrike

1 REPLY 1
Read only

Former Member
0 Likes
381

My Solution is in this format:

In the transformation I have defined a placeholder.


    <MatClassParams>
     </MatClassParams>


In code I use the placeholder in an XML string with the relevant requirements.


CALL TRANSFORMATION ZTEST
SOURCE para = TESTDATA
RESULT XML xml_string.


   " create MatClassParamString Placeholder
   CLEAR xml_string_SUB.
   CONCATENATE '<MatClassParams ' ' ' INTO xml_string_SUB.
   LOOP AT TESTDATA-MATCLASSPARAM-matclassparam[] INTO ls_table_line.
     "COL1 = COL2
     CONCATENATE xml_string_SUB ls_table_line-COL1 '="' ls_table_line-COL2 '" ' INTO xml_string_SUB.
   ENDLOOP.
   CONCATENATE xml_string_SUB '/>' INTO xml_string_SUB.
 

    "find Placeholder in original XMLString
   SPLIT xml_string AT '<MatClassParams/>' INTO xml_string1 xml_string2.

    " insert new MatClassParamString
   CONCATENATE xml_string1 xml_string_SUB xml_string2 INTO xml_string.


Result:

...

<MatClassParams PRODUCT="EPI"DEVICE DESIGN="CMOS"/>

...