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

Simple transformation - attribute and value

Former Member
0 Likes
4,532

Hi,

I have to write a transformation for XML which contains below part:

       <MAIN_NODE>

          <NODE_ID type="some_type">2112434324</NODE_ID>

       </MAIN_NODE>

destination is a table type with structure:

ZMAIN_NODE:

- TYPE

- CONTENT

so ZMAIN_NODE-TYPE shold equal "some_type" and ZMAIN_NODE-CONTENT should be 2112434324.

Transformation always throws shortdump saying:

Expected was element-end: "NODE_ID" [ ] Read was text: 2112434324 [ ].

I tried so many combinations in simple transformation that it doesn't make sense to paste them here.

Please advise how the transformation should look like.

thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
1,997

Solved by myself. Seems that first attribute and node value has to be read to variable.

<tt:ref name=".MAIN_NODE.NODE_ID">

                  <tt:loop>

                       <NODE_ID>

                             <tt:attribute name="type">

                               <tt:read type="C" var="_TYPE"/>

                               <tt:assign to-ref="$REF.TYPE" var="_TYPE"/>

                             </tt:attribute>

                             <tt:read type="C" var="_CONT"/>

                             <tt:assign to-ref="$REF.CONTENT" var="_CONT"/>

                       </NODE_ID>

                  </tt:loop>

</tt:ref>

4 REPLIES 4
Read only

Former Member
0 Likes
1,997

You could post the transformation source code and ABAP code.

Also post bigger XML sample that clarifies what occurs multiple times, MAIN_NODE or NODE_ID.

It would help pinpoint the issue.

Read only

Former Member
0 Likes
1,997

Hi,

Please check the below link:

http://scn.sap.com/docs/DOC-35493

Hope it serves useful to you.

Thanks

Akankshi

Read only

Former Member
0 Likes
1,997

Try it this way.

http://scn.sap.com/thread/1576904

You may also check this link.

https://scn.sap.com/docs/DOC-24791

Thanks,
Susmitha

Read only

Former Member
1,998

Solved by myself. Seems that first attribute and node value has to be read to variable.

<tt:ref name=".MAIN_NODE.NODE_ID">

                  <tt:loop>

                       <NODE_ID>

                             <tt:attribute name="type">

                               <tt:read type="C" var="_TYPE"/>

                               <tt:assign to-ref="$REF.TYPE" var="_TYPE"/>

                             </tt:attribute>

                             <tt:read type="C" var="_CONT"/>

                             <tt:assign to-ref="$REF.CONTENT" var="_CONT"/>

                       </NODE_ID>

                  </tt:loop>

</tt:ref>