Application Development 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: 

XML to Internal Table Error

Former Member
0 Kudos

Hello,

I am trying to upload XML file using call transformation. I am getting following exception 'CX_ST_MATCH_ELEMENT'. Find the template and code that I used. Please give me some inputs for my problem

XML input

<?xml version="1.0" encoding="UTF-8"?>

-<asx:abap version="1.0" xmlns:asx="http://www.sap.com/abapxml"> -<asx:values> -<NEWCHECK> -<item> <IDNUMBER>03123</IDNUMBER> <NAME>SFSDFSD</NAME> <LOCATION>FSDFSD</LOCATION> <AMOUNT>00121</AMOUNT> </item> -<item> <IDNUMBER>11111</IDNUMBER> <NAME>TEST</NAME> <LOCATION>TEST</LOCATION> <AMOUNT>00012</AMOUNT> </item> -<item> <IDNUMBER>43423</IDNUMBER> <NAME>DSDFSD</NAME> <LOCATION>FSDFDSF</LOCATION> <AMOUNT>00011</AMOUNT> </item> </NEWCHECK> </asx:values> </asx:abap>

XSLT Template

<?sap.transform simple?>

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary" xmlns:def="http://www.sap.com/abapxml/types/defined">

   <tt:root name="ROOT" type="?"/>

   <tt:root name="NEWCHECK" type="ddic:ZNEW"/>

   <tt:template>

     <NEWCHECK>

       <tt:loop ref=".NEWCHECK">

         <ZSTRUCT>

           <IDNUMBER tt:value-ref="IDNUMBER"/>

           <NAME tt:value-ref="NAME"/>

           <LOCATION tt:value-ref="LOCATION"/>

           <AMOUNT tt:value-ref="AMOUNT"/>

         </ZSTRUCT>

       </tt:loop>

     </NEWCHECK>

   </tt:template>

</tt:transform>

Code I used

types: BEGIN OF ZSTRUCT,

   IDNUMBER TYPE ZTABLE-IDNUMBER,

   NAME TYPE ZTABLE-NAME,

   LOCATION TYPE ZTABLE-LOCATION,

   AMOUNT TYPE ZTABLE-AMOUNT,

   END OF ZSTRUCT.

   data: XML type string.

   data: lt_msg type ty_msg.

DATA : lt_data TYPE STANDARD TABLE OF ZSTRUCT,

         wa_data type ZSTRUCT,

         wa_msg LIKE LINE OF lt_msg.

TRY.

     CALL TRANSFORMATION ZZTABLE1

     SOURCE XML XML

     RESULT NEWCHECK = lt_data.

   CATCH cx_st_error.

ENDTRY.

Please help me.

1 ACCEPTED SOLUTION

VijayCR
Active Contributor
0 Kudos

CHeck whether all the opened nodes are closed?

4 REPLIES 4

Former Member
0 Kudos

In the XML file change the encoding to UTF-16 and it will upload.

VijayCR
Active Contributor
0 Kudos

CHeck whether all the opened nodes are closed?

Former Member
0 Kudos

Hello,

It has been solved thanks for your reply........

VijayCR
Active Contributor
0 Kudos

This message was moderated.