Skip to Content
avatar image
Former Member

Simple Transformation CX_ST_MATCH_ELEMENT


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.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Dec 23, 2016 at 06:20 PM

    " 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?>" xmlns:ddic="" xmlns:def="">
    <tt:root name="BILL_REQUEST" type="ddic:ZTTBILL_XML_IN"/>
    <tt:loop ref=".BILL_REQUEST">
    <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"/>
    <tt:loop ref="ATTRIBUTES">
    <NAME tt:value-ref="NAME"/>
    <VALUE tt:value-ref="VALUE"/>
    <START_DATE tt:value-ref="START_DATE"/>
    <END_DATE tt:value-ref="END_DATE"/>


    Add comment
    10|10000 characters needed characters exceeded

    • 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)

      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.
      '<?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
      *'<SHADOW_RATE/>' " <=========== REMOVE
      '</BILL_REQUEST>' " <=========== ADD
      INTO xml.
          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.