Skip to Content
0

Simple Transformation CX_ST_MATCH_ELEMENT

Dec 23, 2016 at 06:16 PM

181

avatar image

Hi,

I am using simple transformation to convert XML to ABAP. The XML is getting read correctly just the last line of the XML throws the exception CX_ST_MATCH_ELEMENT for a certain element.

It is always the last record which gives this issue. If i add more records below the last one the one which had the issue does not cause any problems the new last record will cause the record to dump. All the other lines load the element correctly when i debug thru the XML.

Thanks

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Abhishek Dhoundiyal Dec 23, 2016 at 06:20 PM
0

" The error message is below

The exception, which is assigned to class 'CX_ST_MATCH_ELEMENT' was not caught and therefore caused a runtime error. The reason for the exception is: XML comparison error Expected element-end: "BEGABRPE" [ ] Read invalid: " " [ ].

-- The XML

<?sap.transform simple?>
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="BILL_REQUEST" type="ddic:ZTTBILL_XML_IN"/>
<tt:template>
<BILL_REQUEST>
<tt:loop ref=".BILL_REQUEST">
<ZBILL_XML_IN>
<MASS_GUID tt:value-ref="MASS_GUID"/>
<ITEM_GUID tt:value-ref="ITEM_GUID"/>
<ENDABRPE tt:value-ref="ENDABRPE"/>
<BEGABRPE tt:value-ref="BEGABRPE"/>
<SOURCE_SYSTEM tt:value-ref="SOURCE_SYSTEM"/>
<REQUEST_TYPE tt:value-ref="REQUEST_TYPE"/>
<ACTION tt:value-ref="ACTION"/>
<STATUS tt:value-ref="STATUS"/>
<ATTRIBUTES>
<tt:loop ref="ATTRIBUTES">
<ZBILL_REQUEST_AT>
<NAME tt:value-ref="NAME"/>
<VALUE tt:value-ref="VALUE"/>
<START_DATE tt:value-ref="START_DATE"/>
<END_DATE tt:value-ref="END_DATE"/>
</ZBILL_REQUEST_AT>
</tt:loop>
</ATTRIBUTES>
</ZBILL_XML_IN>
</tt:loop>
</BILL_REQUEST>
</tt:template>
</tt:transform>

Thanks

Show 3 Share
10 |10000 characters needed characters left characters exceeded

It should work with the following XML input (that should insert one initial line into the target internal table). Could you check it? If it works, then check what is different with your own XML input.

<?xml version="1.0"?>
<BILL_REQUEST>
<ZBILL_XML_IN>
<MASS_GUID/>
<ITEM_GUID/>
<ENDABRPE/>
<BEGABRPE/>
<SOURCE_SYSTEM/>
<REQUEST_TYPE/>
<ACTION/>
<STATUS/>
<ATTRIBUTES/>
</ZBILL_XML_IN>
</BILL_REQUEST>

0

Hi Sandra,

Thanks for your response. Attributes is deep structure within my original XML. Its a table structure. I never faced this issue when i had a simple structure. This issue started happening once i added the deep structure. I am still facing the issue in the last line. The field <BEGABRPE> is where it error's out ... any idea

<ZBILL_XML_IN>

<MASS_GUID>1</MASS_GUID>

<ITEM_GUID>00000000000005000757</ITEM_GUID>

<ENDABRPE>2016-05-31</ENDABRPE>

<BEGABRPE>2016-05-01</BEGABRPE>

<SOURCE_SYSTEM>B</SOURCE_SYSTEM>

<REQUEST_TYPE>B</REQUEST_TYPE>

<ACTION>B</ACTION> <SHADOW_RATE/>

<STATUS>N</STATUS>

<ATTRIBUTES> <ZBILL_REQUEST_AT> <NAME>SHADOW_RATE</NAME> <VALUE>1234</VALUE> <START_DATE>0000-00-00</START_DATE> <END_DATE>2016-05-31</END_DATE> </ZBILL_REQUEST_AT> <ZBILL_REQUEST_AT> <NAME>SHADOW_RATE1</NAME> <VALUE>1234</VALUE> <START_DATE>0000-00-00</START_DATE> <END_DATE>2016-05-31</END_DATE> </ZBILL_REQUEST_AT> </ATTRIBUTES>

</ZBILL_XML_IN>

0

If you had tried with the XML I have provided, you would have noticed it works, and that's because I have added a required root node, because in your ST you're looping over ZBILL_XML_IN, which means it cannot be a root (there can't be several root nodes).

The following code works (note that I have also removed SHADOW_RATE because it's not in your ST)

REPORT.
TYPES : BEGIN OF ty_ls_zbill_request_at,
                name        TYPE string,
                value       TYPE string,
                start_date  TYPE string,
                end_date    TYPE string,
  END OF ty_ls_zbill_request_at,
BEGIN OF ty_ls_zbill_xml_in,
          mass_guid     TYPE string,
          item_guid     TYPE string,
          endabrpe      TYPE string,
          begabrpe      TYPE string,
          source_system TYPE string,
          request_type  TYPE string,
          action        TYPE string,
          status        TYPE string,
          attributes TYPE STANDARD TABLE OF ty_ls_zbill_request_at WITH DEFAULT KEY,
        END OF ty_ls_zbill_xml_in.
DATA: lt_zbill_xml_in TYPE TABLE OF ty_ls_zbill_xml_in,
      xml TYPE string.
CONCATENATE
'<?xml version="1.0"?>'
'<BILL_REQUEST>' " <=========== ADD a root because, as you are looping over
                 " ZBILL_XML_IN consequently this latter cannot be the root
'<ZBILL_XML_IN>'
'<MASS_GUID>1</MASS_GUID>'
'<ITEM_GUID>00000000000005000757</ITEM_GUID>'
'<ENDABRPE>2016-05-31</ENDABRPE>'
'<BEGABRPE>2016-05-01</BEGABRPE>'
'<SOURCE_SYSTEM>B</SOURCE_SYSTEM>'
'<REQUEST_TYPE>B</REQUEST_TYPE>'
'<ACTION>B</ACTION>'
*'<SHADOW_RATE/>' " <=========== REMOVE
'<STATUS>N</STATUS>'
'<ATTRIBUTES> <ZBILL_REQUEST_AT> <NAME>SHADOW_RATE</NAME> <VALUE>1234</VALUE> <START_DATE>0000-00-00</START_DATE> '
'<END_DATE>2016-05-31</END_DATE> </ZBILL_REQUEST_AT> <ZBILL_REQUEST_AT> <NAME>SHADOW_RATE1</NAME> <VALUE>1234</VALUE>'
' <START_DATE>0000-00-00</START_DATE> <END_DATE>2016-05-31</END_DATE> </ZBILL_REQUEST_AT> </ATTRIBUTES>'
'</ZBILL_XML_IN>'
'</BILL_REQUEST>' " <=========== ADD
INTO xml.
TRY.
    CALL TRANSFORMATION zzsro_test13
    SOURCE XML xml
    RESULT bill_request = lt_zbill_xml_in.
    DATA lx_root TYPE REF TO cx_root.
  CATCH cx_root INTO lx_root.
ENDTRY.
BREAK-POINT.
0