Skip to Content
avatar image
Former Member

Simple Transformation CX_ST_MATCH_ELEMENT

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

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?>
    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

    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)

      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.