Simple Transformation - XML to Internal Table Error

I have a webservice call that returns XML.  I need to transform a portion of the response to an internal table, but my simple transformation is not working with loop processing.  I have read through most posts regarding the topic but they're either too old or related to serialization.  There aren't any exceptions thrown, but I don't get any data in the internal table (PAPERWORK root).  Below are some code snippets.  Any ideas on the problem with the XSLT template?  Thanks.
Sample XML:
<?xml version="1.0" encoding="utf-8" ?>
<PrintVersionDataSet>
<Result>
<ReturnCode>W</ReturnCode>
<ReturnMessage>There are reports with later version(s)</ReturnMessage>
</Result>
<Paperwork>
<ReportCode>CVR</ReportCode>
<ReportName>Cover Sheet</ReportName>
<Version>2</Version>
<PrintedDateTime>2009-05-01T09:54:04.1-05:00</PrintedDateTime>
</Paperwork>
<Paperwork>
<ReportCode>SPS</ReportCode>
<ReportName>Sponsor Summary</ReportName>
<Version>2</Version>
<PrintedDateTime>2009-05-01T09:54:04.99-05:00</PrintedDateTime>
</Paperwork>
</PrintVersionDataSet>
XSLT Code:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="RESULT"/>
  <tt:root name="PAPERWORK"/>
  <tt:template>
    <PrintVersionDataSet>
      <Result tt:ref="RESULT">
        <ReturnCode>
          <tt:value ref="RETURNCODE"/>
        </ReturnCode>
        <ReturnMessage>
          <tt:value ref="RETURNMESSAGE"/>
        </ReturnMessage>
      </Result>
      <tt:deserialize>
        <tt:loop ref=".PAPERWORK">
          <Paperwork>
            <ReportCode>
              <tt:value ref="REPORTCODE"/>
            </ReportCode>
            <ReportName>
              <tt:value ref="REPORTNAME"/>
            </ReportName>
            <Version>
              <tt:value ref="VERSION"/>
            </Version>
            <PrintedDateTime>
              <tt:value ref="PRINTEDDATETIME"/>
            </PrintedDateTime>
          </Paperwork>
        </tt:loop>
      </tt:deserialize>
    </PrintVersionDataSet>
  </tt:template>
</tt:transform>
ABAP Call to Transform Data:
TRY.
CALL TRANSFORMATION Z_GA_PAPERWORK_VERS_WEBSVC
      SOURCE XML LS_RESPONSE-VERIFY_PRINT_VERSION_RESULT
      RESULT RESULT     = LS_RESULT
             PAPERWORK  = LT_PAPERWORK.
    CATCH CX_ROOT INTO ROOT_EXCEPTION.
      CALL METHOD ROOT_EXCEPTION->IF_MESSAGE~GET_TEXT
        RECEIVING
          RESULT = LV_MESSAGE.
  ENDTRY.

Upon further inspection and testing with a simple file and program, I can see that the XML structure isn't quite correct for the loop process.  There needs to be a single <PAPERWORK> node, instead of one for each table line in the file.  This should allow the loop to execute properly after a slight adjustment to the XSLT template.

Similar Messages

  • Simple transformation XML to ABAP, runtime error: CX_ST_REF_ACCESS

    Hi, all experts,
    I got a runtime error CX_ST_REF_ACCESS, while I tried to use Simple Transformation to transfer XML-String to ABAP internal table.
    Can anybody help me to fix the problem? Thanks very much. It's urgent.
    The code of transformation like this:
    <tt:root name="DATA"/>
      <tt:template>
        <node>
          <tt:deserialize>
            <tt:loop ref=".DATA" name="mdr_data">
              <tt:attribute name="type">
                <tt:value ref="$mdr_data.lf_type"/>
              </tt:attribute>
              <tt:attribute name="objid">
                <tt:value ref="$mdr_data.lf_objid"/>
              </tt:attribute>
              <tt:attribute name="name" value-ref="$mdr_data.lf_name"/>
              <tt:attribute name="short" value-ref="$mdr_data.lf_short"/>
            </tt:loop>
          </tt:deserialize>
        </node>
      </tt:template>
    The Data-structure in my Report:
    DATA: BEGIN OF ls_mdr_data,
            lf_type TYPE /ehr/ct_dt_bo_type,
            lf_objid TYPE realo,
            lf_name TYPE stext,
            lf_short TYPE short_d,
          END OF ls_mdr_data,
         lt_result_data like TABLE OF ls_mdr_data.
    If I call the transformation use the XML-String like:
    <node type="MDRFOLDER" objid="50016122" name="MDR Root Folder" short="MDR Root"/>
    I got the  error  CX_ST_REF_ACCESS:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not  caught and
        therefore caused a runtime error.
        The reason for the exception is:
        The goal was to access variable "LF_TYPE". However, this access was not
        possible.

    Hi, all experts,
    I got a runtime error CX_ST_REF_ACCESS, while I tried to use Simple Transformation to transfer XML-String to ABAP internal table.
    Can anybody help me to fix the problem? Thanks very much. It's urgent.
    The code of transformation like this:
    <tt:root name="DATA"/>
      <tt:template>
        <node>
          <tt:deserialize>
            <tt:loop ref=".DATA" name="mdr_data">
              <tt:attribute name="type">
                <tt:value ref="$mdr_data.lf_type"/>
              </tt:attribute>
              <tt:attribute name="objid">
                <tt:value ref="$mdr_data.lf_objid"/>
              </tt:attribute>
              <tt:attribute name="name" value-ref="$mdr_data.lf_name"/>
              <tt:attribute name="short" value-ref="$mdr_data.lf_short"/>
            </tt:loop>
          </tt:deserialize>
        </node>
      </tt:template>
    The Data-structure in my Report:
    DATA: BEGIN OF ls_mdr_data,
            lf_type TYPE /ehr/ct_dt_bo_type,
            lf_objid TYPE realo,
            lf_name TYPE stext,
            lf_short TYPE short_d,
          END OF ls_mdr_data,
         lt_result_data like TABLE OF ls_mdr_data.
    If I call the transformation use the XML-String like:
    <node type="MDRFOLDER" objid="50016122" name="MDR Root Folder" short="MDR Root"/>
    I got the  error  CX_ST_REF_ACCESS:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_ST_REF_ACCESS', was not  caught and
        therefore caused a runtime error.
        The reason for the exception is:
        The goal was to access variable "LF_TYPE". However, this access was not
        possible.

  • Transforming XML  into Internal Table

    Hi guys, I have tried a simple nested code but i fail to write in the Name, Phone and Email portion ... I manage to get to the header level... Can any one gimme some pointers?
    PS: I have read to those threads posted here already before I got this far
    <b><u>MAIN CODE</u></b>
    REPORT  ZTESTJASON11.
    TYPES: BEGIN OF T_HEADER,
            NAME(140),
            PHONE(23),
            EMAIL(100),
           END OF T_HEADER,
           D_HEADER TYPE T_HEADER OCCURS 0.
    TYPES: BEGIN OF T_ITEM,
            HEADER TYPE D_HEADER,
           END OF T_ITEM,
           D_ITEM TYPE T_ITEM OCCURS 0.
    TYPES: BEGIN OF T_LIST,
            ITEM TYPE D_ITEM,
           END OF T_LIST,
           D_LIST TYPE T_LIST OCCURS 0.
    TYPES: BEGIN OF TYPE_DATA,
            LIST TYPE D_LIST,
           END OF TYPE_DATA.
    DATA: RESPONSE TYPE TABLE OF TYPE_DATA.
    DATA: XMLOUT TYPE STRING.
    DATA: ITAB LIKE SOLI OCCURS 0 WITH HEADER LINE.
    DATA: HEADER_WA    TYPE T_HEADER,
          HEADER_LN    TYPE D_HEADER,
          ITEM_WA      TYPE T_ITEM,
          ITEM_LN      TYPE D_ITEM,
          LIST_WA      TYPE T_LIST,
          LIST_LN      TYPE D_LIST.
    MOVE:   'JIM BEAN' TO HEADER_WA-NAME,
            '+6512345678' TO HEADER_WA-PHONE,
            '[email protected]' TO HEADER_WA-EMAIL.
    APPEND HEADER_WA TO HEADER_LN.
    ITEM_WA-HEADER = HEADER_LN.
    APPEND ITEM_WA TO ITEM_LN.
    LIST_WA-ITEM = ITEM_LN.
    APPEND LIST_WA TO LIST_LN.
    myXML-LIST = LIST_LN.
    PERFORM UPLOAD_XML.
    FORM UPLOAD_XML .
    REFRESH ITAB.
    clear RESPONSE.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'C:test11.XML'
    filetype = 'BIN'
    TABLES
    data_tab = ITAB.
    LOOP AT ITAB.
      CONCATENATE XMLOUT ITAB-LINE INTO XMLOUT.
    ENDLOOP.
    CALL TRANSFORMATION ('ZTEST11X2A')
    SOURCE XML XMLOUT
    RESULT RESPONSE = RESPONSE.
    BREAK-POINT.
    ENDFORM.
    <b><u>XML CODE (test11.xml)</u></b>
    <?xml version="1.0" encoding="iso-8859-1"?>
    <myXML>
      <LIST>
        <ITEM>
          <HEADER>
            <NAME>JIM BEAN</NAME>
            <PHONE>+6512345678</PHONE>
            <EMAIL>[email protected]</EMAIL>
          </HEADER>
        </ITEM>
      </LIST>
    </myXML>           
    <b><u>XSLT CODE (ZTEST11X2A)</u></b>
    <xsl:transform version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:sap="http://www.sap.com/abapxml"
    >
    <xsl:template match="/">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml">
    <asx:values>
        <RESPONSE>
          <myXML>
           <LIST>
           <ITEM>
            <xsl:for-each select="ITEM">
                <I>
                    <HEADER>
                        <NAME> <xsl:value-of select="NAME"/> </NAME>
                        <PHONE> <xsl:value-of select="PHONE"/> </PHONE>
                        <EMAIL> <xsl:value-of select="EMAIL"/> </EMAIL>
                    </HEADER>
                </I>
             </xsl:for-each>
             </ITEM>
            </LIST>
            </myXML>
        </RESPONSE>
    </asx:values>
    </asx:abap>
    </xsl:template>
    </xsl:transform>

    Thanks a million in advance Raja, thanks for ur help, realli appreaciate it! ")
    Here it is...
    <u><b>MAIN CODE (itab declaration)</b></u>
    REPORT  ZTESTJASON11.
    TYPES: BEGIN OF T_HEADER,
            NAME(140),
            PHONE(23),
            EMAIL(100),
           END OF T_HEADER,
           D_HEADER TYPE T_HEADER OCCURS 0.
    TYPES: BEGIN OF T_ITEM,
            HEADER TYPE D_HEADER,
           END OF T_ITEM,
           D_ITEM TYPE T_ITEM OCCURS 0.
    TYPES: BEGIN OF T_LIST,
            ITEM TYPE D_ITEM,
           END OF T_LIST,
           D_LIST TYPE T_LIST OCCURS 0.
    TYPES: BEGIN OF TYPE_DATA,
            LIST TYPE D_LIST,
           END OF TYPE_DATA.
    DATA: RESPONSE TYPE TABLE OF TYPE_DATA.
    DATA: XMLOUT TYPE STRING.
    DATA: ITAB LIKE SOLI OCCURS 0 WITH HEADER LINE.
    DATA: HEADER_WA    TYPE T_HEADER,
          HEADER_LN    TYPE D_HEADER,
          ITEM_WA      TYPE T_ITEM,
          ITEM_LN      TYPE D_ITEM,
          LIST_WA      TYPE T_LIST,
          LIST_LN      TYPE D_LIST.
    MOVE:   'JIM BEAN' TO HEADER_WA-NAME,
            '+6512345678' TO HEADER_WA-PHONE,
            '[email protected]' TO HEADER_WA-EMAIL.
    APPEND HEADER_WA TO HEADER_LN.
    ITEM_WA-HEADER = HEADER_LN.
    APPEND ITEM_WA TO ITEM_LN.
    LIST_WA-ITEM = ITEM_LN.
    APPEND LIST_WA TO LIST_LN.
    myXML-LIST = LIST_LN.
    PERFORM UPLOAD_XML.
    FORM UPLOAD_XML .
    REFRESH ITAB.
    clear RESPONSE.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'C:test11.XML'
    filetype = 'BIN'
    TABLES
    data_tab = ITAB.
    LOOP AT ITAB.
      CONCATENATE XMLOUT ITAB-LINE INTO XMLOUT.
    ENDLOOP.
    CALL TRANSFORMATION ('ZTEST11X2A')
    SOURCE XML XMLOUT
    RESULT RESPONSE = RESPONSE.
    BREAK-POINT.
    ENDFORM.
    <u><b>XML CODE (test11.xml)</b></u>
    <?xml version="1.0" encoding="iso-8859-1"?>
    <myXML>
      <LIST>
        <ITEM>
          <HEADER>
            <NAME>JIM BEAN</NAME>
            <PHONE>+6512345678</PHONE>
            <EMAIL>[email protected]</EMAIL>
          </HEADER>
        </ITEM>
      </LIST>
    </myXML>          
    <u><b>XSLT CODE (ZTEST11X2A)</b></u>
    <xsl:transform version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:sap="http://www.sap.com/abapxml"
    >
    <xsl:template match="/">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml">
    <asx:values>
          <RESPONSE>
          <myXML>
           <LIST>
            <ITEM>
            <xsl:for-each select="ITEM">
                <dataset1>
                        <HEADER>
                        <xsl:for-each select="HEADER">
                        <dataset2>
                                <NAME>
                                    <xsl:value-of select="NAME"/>
                                </NAME>
                                <PHONE>
                                    <xsl:value-of select="PHONE"/>
                                </PHONE>
                                <EMAIL>
                                    <xsl:value-of select="EMAIL"/>
                                </EMAIL>
                       </dataset2>
                       </xsl:for-each>
                       </HEADER>
                </dataset1>
             </xsl:for-each>
            </ITEM>
            </LIST>
            </myXML>
            </RESPONSE>
    </asx:values>
    </asx:abap>
    </xsl:template>
    </xsl:transform>

  • Simple transformation error in converting XML to internal table

    Hi Team,
    I have an issue, its working in Dev, QA, and Prod in PI 7.0, once we upgrade it to PI 7.1 I'm getting the  below mention error,   
    Unknown Simple transformation error in converting XML to internal table
    Application error in mapping program ZF_INT006_FILE_TO_SAP_FILE, error code: , error text: Unknown Simple transformation error in converting XML to internal table An exception has occurred.
    Can any one suggest related notes are suggestion.
    appericate in advance for the solutions which you all provide me
    Thank you
    Venkat Anil

    Check the flag "use SAP XML toolkit" for the operation mapping and try, if that works then.
    Check the flag for all XSLT and Java mappings which is migrated from PI 7.0

  • Reading data from XML to Internal table

    Hi Experts,
    I got a requirement to read the data fom xml to internal table.is it possible to store deep internel table data into flat internal tables?my internel table contains 4 internel table and these 4 internel table contains 2 internel tables each...can any one help me o this...
    points will be rewarded...
    Regards,
    Rakhi

    Hi Rakhi,
    * Structure to Get the Client Details as in XML format
      DATA: BEGIN OF client,
              BEGIN OF Personal_Details,
                kunnr like kna1-kunnr,
                name1 like kna1-name1,
                adrnr like kna1-adrnr,
              END OF Personal_Details,
              BEGIN OF Address,
                street like adrc-street,
                city1  like adrc-city1,
              END OF Address,
              BEGIN OF Communication,
                fax_number like adrc-fax_number,
                tel_number like adrc-tel_number,
              END OF Communication,
            END OF client.
      DATA: it_client TYPE TABLE OF client WITH HEADER LINES,
            result LIKE client.
      DATA: xml_string TYPE string.
    *  Get the Client Details into the structure to be made as an XML string
      TRY.
    *  Convert the Structure to XML string
          CALL TRANSFORMATION  ('ID')
            SOURCE para = it_client
            RESULT XML xml_string.
    *  Convert the XML string to structure - result
          CALL TRANSFORMATION  ('ID')
            SOURCE XML xml_string
            RESULT para = result.
      CATCH cx_st_error.
      ENDTRY.
    best regards,
    Thangesh

  • Xml to Internal table : Issue

    Dear All,
    I have written a program to bring the data from xml to internal table  Below is the strucutre of my xml file .
    - <Data>
    - <MT Type="CR">
      <MatType>FERT</MatType>
      </MT>
    - <OP Type="CR">
      <MatNumber>9901040103-000115</MatNumber>
    - <Activities Element="AT">
    - <AT Type="CR">
      <MaterialNumber>115</MaterialNumber>
      <ActivityType>DEPR.</ActivityType>
      </AT>
    - <AT Type="CR">
      <MaterialNumber>117</MaterialNumber>
      <ActivityType>L.C.R</ActivityType>
      </AT>
      </Activities>
      </OP>
      </Data>
    .However I am not able to handle the multiple entries which comes together . ie
    - <AT Type="CR">
      <MaterialNumber>115</MaterialNumber>
      <ActivityType>DEPR.</ActivityType>
      </AT>
    - <AT Type="CR">
      <MaterialNumber>117</MaterialNumber>
      <ActivityType>L.C.R</ActivityType>
      </AT>
    Please let me know how to handle this . Thanks!
    Regards,
    Syed

    Hi ,
    To convert XML data into internal table u have to use FM "SMUM_XML_PARSE", this FM takes XString as input ,so first u have to
    convert  ur xml string into XString using FM "SCMS_STRING_TO_XSTRING".
    Thanks
    jitendra

  • XML to Internal table using XSLT by CALL TRANSFORMATION error

    Dear experts,
    I have to fetch the data from an XML file using XSLT into internal tables. The XML file is very big as following:-
    <?xml version="1.0" standalone="yes" ?>
    - <Shipment>
      <shipmentID>25091203S000778</shipmentID>
      <manifestDateTime>2009-12-03T20:16:52.00</manifestDateTime>
      <shipmentFacilityNumber>025</shipmentFacilityNumber>
      <shipmentFacilityAbbreviation>CHI</shipmentFacilityAbbreviation>
      <shipmentFacilityAddress1>810 KIMBERLY DRIVE</shipmentFacilityAddress1>
      <shipmentFacilityAddress2 />
      <shipmentFacilityCity>CAROL STREAM</shipmentFacilityCity>
      <shipmentFacilityState>IL</shipmentFacilityState>
      <shipmentFacilityPostalCode>601880000</shipmentFacilityPostalCode>
      <shipmentTruckCarrierCode>X150</shipmentTruckCarrierCode>
      <shipmentSourceCode>T</shipmentSourceCode>
      <userID>CAMPOSG</userID>
    - <Delivery>
      <primaryCustomerNumber>954371</primaryCustomerNumber>
      <primaryCustomerName>MIDWEST OFFICE SUPPLY</primaryCustomerName>
      <primaryCustomerAddress1 />
      <primaryCustomerAddress2>4765 INDUSTRIAL DR</primaryCustomerAddress2>
      <primaryCustomerCity>SPRINGFIELD</primaryCustomerCity>
      <primaryCustomerState>IL</primaryCustomerState>
      <primaryCustomerPostalCode>627030000</primaryCustomerPostalCode>
      <primaryCustomerPhoneNumber>2177535555</primaryCustomerPhoneNumber>
      <shuttleStopFacilityNumber />
      <billOfLadingNumber>25HZK99</billOfLadingNumber>
      <carrierProNumber />
      <shipmentTotalCartonCount>6</shipmentTotalCartonCount>
      <shipmentTotalWeight>266</shipmentTotalWeight>
    - <order>
      <orderNumber>25HZK99</orderNumber>
      <subOrderNumber />
      <dateProcessed>2009-12-03</dateProcessed>
      <primaryOrderNumber />
      <shipTruckCode>X150</shipTruckCode>
      <shipTruckDescription>UDS - ADDISON</shipTruckDescription>
      <shipTruckPriorityCode>01</shipTruckPriorityCode>
      <shipTruckGroupCode>01</shipTruckGroupCode>
      <shipTruckDepartureTime>20.00.00</shipTruckDepartureTime>
      <shipTruckDockID>07</shipTruckDockID>
      <ldpFacilityAbbreviation />
      <shuttleAvailableIndicator>N</shuttleAvailableIndicator>
      <shuttleMessageText />
      <crossDockFacilityCode />
      <crossDockTruckCode />
      <crossDockID />
      <subsidizedFreightTruckID />
      <customerPurchaseOrderNumber>623559</customerPurchaseOrderNumber>
      <headerTypeCode>P</headerTypeCode>
      <orderTypeID>RG</orderTypeID>
      <deliveryTypeID>DS</deliveryTypeID>
      <deliveryMethodCode />
      <customerBarCode />
      <customerReferenceData>25HZK99</customerReferenceData>
      <customerReferenceText />
      <customerRouteData>ZNED UNTED</customerRouteData>
      <customerRouteText>ROUTE</customerRouteText>
      <endConsumerPurchaseOrderNumber />
      <endConsumerPurchaseOrderText />
      <endConsumerName>CHARLESTON TRANS. FACILITY</endConsumerName>
      <endConsumerAddress1>HOMEWOOD DT PROGRAM DEPT. 3</endConsumerAddress1>
      <endConsumerAddress2>17341 PALMER BLVD.</endConsumerAddress2>
      <endConsumerAddress3 />
      <endConsumerCity>HOMEWOOD</endConsumerCity>
      <endConsumerState>IL</endConsumerState>
      <endConsumerPostalCode>60430</endConsumerPostalCode>
      <endConsumerCountryCode />
      <fillFacilityNumber>025</fillFacilityNumber>
      <shpFacilityNumber>025</shpFacilityNumber>
      <homeFacilityAbbrCode>STL</homeFacilityAbbrCode>
      <homeFacilityNumber>015</homeFacilityNumber>
      <multiCartonIndicator>Y</multiCartonIndicator>
      <primaryCustomerIndicator>Y</primaryCustomerIndicator>
      <shipToCustomerNumber>954371001</shipToCustomerNumber>
      <customerCompanyID>01</customerCompanyID>
      <customerTruckID>U888</customerTruckID>
      <customerTruckDescription>UDS - ADDISON</customerTruckDescription>
      <customerTruckDockID>13</customerTruckDockID>
      <thirdPartyBillCarrier />
      <thirdPartyBillID />
      <thirdPartyBillType />
      <qualityCheckIndicator>N</qualityCheckIndicator>
      <warehouseLaydownID />
      <packListPosition>I</packListPosition>
      <preferredPackingType>CTN</preferredPackingType>
      <preferredPackingMaterial>PAPER</preferredPackingMaterial>
      <preferedPackingInstructions />
      <totalOrderCartonQty>6</totalOrderCartonQty>
      <convertAddressIndicator>N</convertAddressIndicator>
      <dealerInstructionIndicator>Y</dealerInstructionIndicator>
      <dealerinstructions1>CPO#: 623559</dealerinstructions1>
      <dealerinstructions2>ATTN: DANA GRIFFIN</dealerinstructions2>
      <dealerinstructions3>INFO: 612</dealerinstructions3>
      <dealerinstructions4>ROUTE: ZNED UNTED</dealerinstructions4>
      <dealerinstructions5 />
      <dealerinstructions6 />
      <shippingInstructionsIndicator>N</shippingInstructionsIndicator>
      <shippingInstructions1 />
      <shippingInstructions2 />
      <shippingInstructions3 />
      <shippingInstructions4 />
      <shippingInstructions5 />
      <shippingInstructions6 />
      <specialInstructionsIndicator>N</specialInstructionsIndicator>
      <specialInstructions1 />
      <specialInstructions2 />
      <customeContainerDesc />
    - <carton>
      <deliveryCartonID>253370905995</deliveryCartonID>
      <shipIndicator>Y</shipIndicator>
      <deliveryPalletID>X150</deliveryPalletID>
      <consolidatedDeliveryCartonID />
      <scanDateTime>2009-12-03T19:36:12.00</scanDateTime>
      <cartonWeight>52</cartonWeight>
      <dropShipFlag>1</dropShipFlag>
      <carrierTrackingNumber />
      <carrierZoneID>0</carrierZoneID>
      <codAmount />
      <customerPackageAmount />
      <declaredValue />
      <residentialDeliveryIndicator />
      <serviceTypeCode>00</serviceTypeCode>
      <ssccCode>006860244400829393</ssccCode>
    - <Item>
      <shipPrefix>UNV</shipPrefix>
      <shipStockNumber>21200</shipStockNumber>
      <itemDescription>PAPER XERO/DUP WE LTR 20#</itemDescription>
      <orderQuantity>1</orderQuantity>
      <originalShipQuantity>1</originalShipQuantity>
      <shipQuantity>1</shipQuantity>
      <inventoryUnitCode>CT</inventoryUnitCode>
      <inventoryWeightQuantity>52.000</inventoryWeightQuantity>
      <upcNumber>00000000000000</upcNumber>
      <upcRetailCode>087547212004</upcRetailCode>
      <hazmatIndicator>N</hazmatIndicator>
      <serialRequiredIndicator>N</serialRequiredIndicator>
      <dealerMemoPO>S</dealerMemoPO>
      <cartonLineNumber>1</cartonLineNumber>
      <orderLineNumber>11</orderLineNumber>
      <originalOrderPrefix>UNV</originalOrderPrefix>
      <originalOrderStockNumber>21200</originalOrderStockNumber>
      <reasonCode />
    - <Item_Serial>
      <serialNumber />
      </Item_Serial>
        </Item>
      </carton>
       </order>
      </Delivery>
      </Shipment>
    This is not the complete XML file as it exceeds the 15000 characters and then I cann't post here. So I have deleted much part of it.
    The hierarchy is as following: Shipment->Delivery->Order->Carton->Item.
    I have created a XSLT for it which is working fine.
    But when I execute my report program it gives CX_SY_XSLT_FORMAT_ERROR saying that
    Transformation error:  Non-canonical structure of element name XML_OUTPUT.

    Dear experts,
    My report program is as following:-
    *& Report  Z_ASNTRNS
    REPORT  Z_ASNTRNS.
    *& Report  Z_ASNTRNS
    TYPE-POOLS: abap, ixml.
    TABLES: ZASN_SHIPMENT,ZASN_DELIVERY,ZASN_ORDER,ZASN_CARTON,ZASN_ITEM.
    *CONSTANTS gs_file TYPE string VALUE 'C:Documents and SettingsC5134126DesktopRajesh_kandakatlaSampleASNFile.xml'.
    This is the structure for the data from the XML file
    TYPES: BEGIN OF ts_item,
          ZSHIPMENT LIKE ZASN_ITEM-ZSHIPMENT,
          VBELN LIKE ZASN_ITEM-VBELN,
          ORDER_NUMBER LIKE ZASN_ITEM-ORDER_NUMBER,
          CARTON_ID LIKE ZASN_ITEM-CARTON_ID,
           ITEM LIKE ZASN_ITEM-ITEM,
           CARTON_LINE_NUM LIKE ZASN_ITEM-CARTON_LINE_NUM,
           CARTON_LINE_NUMBER LIKE ZASN_ITEM-CARTON_LINE_NUM,
          AEDAT(8),
          AEZET(6),
           ITEM_DESCRIPTION LIKE ZASN_ITEM-ITEM_DESCRIPTION,
           ORD_QTY(16),
           ORIGINAL_SHIP(16),
           SHIP_QTY(16),
           UPC_NUMBER LIKE ZASN_ITEM-UPC_NUMBER,
           DEALER_MEMO_PO(5),
           ORDER_LINE_NUM LIKE ZASN_ITEM-ORDER_LINE_NUM,
          STATUS LIKE ZASN_ITEM-STATUS,
           END OF ts_item.
    TYPES: BEGIN OF ts_carton,
          ZSHIPMENT LIKE ZASN_CARTON-ZSHIPMENT,
          VBELN LIKE ZASN_CARTON-VBELN,
          ORDER_NUMBER LIKE ZASN_CARTON-ORDER_NUMBER,
           CARTON_ID LIKE ZASN_CARTON-CARTON_ID,
          AEDAT(8),
          AEZET(6),
           SHIP_INDICATOR LIKE ZASN_CARTON-SHIP_INDICATOR,
           TRACKING_NUMBER LIKE ZASN_CARTON-TRACKING_NUMBER,
           ZZCARTON_WGT(18),
           Item type ts_item,
           END OF ts_carton.
    TYPES: BEGIN OF ts_order,
          ZSHIPMENT LIKE ZASN_ORDER-ZSHIPMENT,
          VBELN LIKE ZASN_ORDER-VBELN,
           ORDER_NUMBER LIKE ZASN_ORDER-ORDER_NUMBER,
          AEDAT(8),
          AEZET(6),
           SUB_ORDER LIKE ZASN_ORDER-SUB_ORDER,
           ORDER_DATE(8),
           PRIMARY_ORDER LIKE ZASN_ORDER-PRIMARY_ORDER,
           CUSTOMER_PO LIKE ZASN_ORDER-CUSTOMER_PO,
           PRIMARY_ID LIKE ZASN_ORDER-PRIMARY_ID,
           SHIP_TO LIKE ZASN_ORDER-SHIP_TO,
          ANZPK(5),
           carton type ts_carton,
           END OF ts_order.
    TYPES: BEGIN OF ts_delivery,
          ZSHIPMENT LIKE ZASN_DELIVERY-ZSHIPMENT,
          VBELN LIKE ZASN_DELIVERY-VBELN,
          AEDAT(8) TYPE C,
          AEZET(6) TYPE C,
           PRIMARY_CUSTOMER LIKE ZASN_DELIVERY-PRIMARY_CUSTOMER,
           BILL_OF_LADING LIKE ZASN_DELIVERY-BILL_OF_LADING,
           CARTON_COUNT(5),
           TOTAL_WEIGHT(18),
           order type ts_order,
           END OF ts_delivery.
    TYPES: BEGIN OF ts_shipment,
           ZSHIPMENT LIKE ZASN_SHIPMENT-ZSHIPMENT,
           MANIFEST_DATE_TIME(25),
          AEDAT(8) TYPE C,
          AEZET(6) TYPE C,
          SDATE(8) TYPE C,
          STIME(6) TYPE C,
           SFACILITY_NUMBER LIKE ZASN_SHIPMENT-SFACILITY_NUMBER,
           ZZCARRIERCODE LIKE ZASN_SHIPMENT-ZZCARRIERCODE,
           Delivery type ts_delivery,
           END OF ts_shipment.
    TYPES: BEGIN OF ts_shipment1,
           ZSHIPMENT LIKE ZASN_SHIPMENT-ZSHIPMENT,
           MANIFEST_DATE_TIME(25),
           SFACILITY_NUMBER LIKE ZASN_SHIPMENT-SFACILITY_NUMBER,
           ZZCARRIERCODE LIKE ZASN_SHIPMENT-ZZCARRIERCODE,
           PRIMARY_CUSTOMER LIKE ZASN_DELIVERY-PRIMARY_CUSTOMER,
           BILL_OF_LADING LIKE ZASN_DELIVERY-BILL_OF_LADING,
           CARTON_COUNT(5),
           TOTAL_WEIGHT(18),
           ORDER_NUMBER LIKE ZASN_ORDER-ORDER_NUMBER,
           SUB_ORDER LIKE ZASN_ORDER-SUB_ORDER,
           ORDER_DATE(8),
           PRIMARY_ORDER LIKE ZASN_ORDER-PRIMARY_ORDER,
           CUSTOMER_PO LIKE ZASN_ORDER-CUSTOMER_PO,
           PRIMARY_ID LIKE ZASN_ORDER-PRIMARY_ID,
           SHIP_TO LIKE ZASN_ORDER-SHIP_TO,
           CARTON_ID LIKE ZASN_CARTON-CARTON_ID,
           SHIP_INDICATOR LIKE ZASN_CARTON-SHIP_INDICATOR,
           TRACKING_NUMBER LIKE ZASN_CARTON-TRACKING_NUMBER,
           ZZCARTON_WGT(18),
           ITEM LIKE ZASN_ITEM-ITEM,
           CARTON_LINE_NUM LIKE ZASN_ITEM-CARTON_LINE_NUM,
           CARTON_LINE_NUMBER LIKE ZASN_ITEM-CARTON_LINE_NUM,
           ITEM_DESCRIPTION LIKE ZASN_ITEM-ITEM_DESCRIPTION,
           ORD_QTY(16),
           ORIGINAL_SHIP(16),
           SHIP_QTY(16),
           UPC_NUMBER LIKE ZASN_ITEM-UPC_NUMBER,
           DEALER_MEMO_PO(5),
           ORDER_LINE_NUM LIKE ZASN_ITEM-ORDER_LINE_NUM,
           END OF ts_shipment1.
    TYPES: BEGIN OF t_xml_line,
                 data(256) TYPE x,
               END OF t_xml_line.
    *Typdefinition für Airplus
    *READ THE DOCUMENTATION "LASG_XML_INVOICE_BTM"!!!
    VARs beginning with "a_" are ATTRIBUTES
    DATA: l_ixml            TYPE REF TO if_ixml,
          l_streamfactory   TYPE REF TO if_ixml_stream_factory,
          l_parser          TYPE REF TO if_ixml_parser,
          l_istream         TYPE REF TO if_ixml_istream,
          l_ostream         TYPE REF TO if_ixml_ostream,
          l_document        TYPE REF TO if_ixml_document,
          l_node            TYPE REF TO if_ixml_node,
          l_xml TYPE REF TO cl_xml_document,
          l_xmldata         TYPE string.
    DATA: l_xml_table       TYPE TABLE OF t_xml_line,
             l_xml_line        TYPE t_xml_line,
             l_xml_table_size  TYPE i.
    DATA: l_filename        TYPE string.
    DATA: xml_out TYPE string ,
          size type i.
    DATA: l_xml_x1   TYPE xstring.
    DATA: l_len      TYPE i,
              l_len2     TYPE i,
              l_tab      TYPE tsfixml,
              l_content  TYPE string,
              l_str1     TYPE string,
              c_conv     TYPE REF TO cl_abap_conv_in_ce.
             l_itab     TYPE TABLE OF string.
    DATA: BEGIN OF l_itab occurs 0,
          data(256) type c,
          end of l_itab.
    TYPES : BEGIN OF TY_TEXT,
              data(255) type C,
            END OF TY_TEXT.
    DATA: F_XML TYPE STRING.
    DATA : LT_TEXT_OUT type table of TY_TEXT with header line.
    tables
    DATA: it_shipment    TYPE STANDARD TABLE OF ts_shipment,
          wa_shipment    TYPE  ts_shipment.
    *Errorvariables
    DATA: xslt_err   TYPE REF TO cx_xslt_exception,
          err_string TYPE string.
    PARAMETERS: pa_file TYPE localfile OBLIGATORY
    DEFAULT 'C:Documents and SettingsC5134126DesktopRajesh_kandakatlaSampleASNFile.xml'.
    START-OF-SELECTION.
      Creating the main iXML factory
        l_ixml = cl_ixml=>create( ).
      Creating a stream factory
        l_streamfactory = l_ixml->create_stream_factory( ).
        PERFORM get_xml_table CHANGING l_xml_table_size l_xml_table.
    here we use the CALL TRANSFORMATION method which calls
    the XSLT program "z_asnfile"
    TRY.
        CALL TRANSFORMATION ('Z_ASNFILE')
          SOURCE xml LT_TEXT_OUT[]
          RESULT xml_output = it_shipment
    catch any error, very helpful if the XSLT isn't correct
        CATCH cx_xslt_exception INTO xslt_err.
        err_string = xslt_err->get_text( ).
        WRITE: / 'Transformation error: ', err_string.
        EXIT.
      ENDTRY." setting a breakpoint to watch the workarea
    by the internal table "it_airplus"
           break-point.
      LOOP AT it_shipment INTO wa_shipment.
      ENDLOOP.
    *&      Form  get_xml_table
      FORM get_xml_table CHANGING l_xml_table_size TYPE i
                                  l_xml_table      TYPE STANDARD TABLE.
        l_filename = pa_file.
      upload a file from the client's workstation
        CALL METHOD cl_gui_frontend_services=>gui_upload
          EXPORTING
            filename   = l_filename
            filetype   = 'BIN'
          IMPORTING
            filelength = l_xml_table_size
          CHANGING
            data_tab   = l_xml_table
          EXCEPTIONS
            OTHERS     = 19.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Convert binary to text.
    CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
      EXPORTING
        INPUT_LENGTH          = 70000
                FIRST_LINE            = 0
                LAST_LINE             = 0
                APPEND_TO_TABLE       = ' '
                MIMETYPE              = ' '
        WRAP_LINES            = 'X'
              IMPORTING
                OUTPUT_LENGTH         =
      TABLES
        BINARY_TAB            = l_xml_table
        TEXT_TAB              = LT_TEXT_OUT
              EXCEPTIONS
                FAILED                = 1
                OTHERS                = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    "get_xml_table

  • Simple Transformation XML to ABAP   - error CX_ST_MATCH_ELEMENT

    Hi all,
    I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    - <asx:values>
      <NETWORK>E60000000000</NETWORK>
      <OPERAZIONE>0010</OPERAZIONE>
    - <TABELLA>
    - <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
      <MANDT>300</MANDT>
      <NETWORK>E60000000000</NETWORK>
      <OPERAZIONE>0010</OPERAZIONE>
      <ID_ACT>1</ID_ACT>
      <DESC_ACT>ATTIVITÀ1</DESC_ACT>
      <LONG_TXT></LONG_TXT>
      <MAKE_BUY></MAKE_BUY>
      <WP></WP>
      <EVENTO_TECH></EVENTO_TECH>
      <TIPO_LEGAME></TIPO_LEGAME>
      <CONSEGNA></CONSEGNA>
      </ROW>
    - <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">
      <MANDT>300</MANDT>
      <NETWORK>E60000000000</NETWORK>
      <OPERAZIONE>0010</OPERAZIONE>
      <ID_ACT>2</ID_ACT>
      <DESC_ACT>ATTIVITÀ2</DESC_ACT>
      <LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT>
      <MAKE_BUY>M</MAKE_BUY>
      <WP></WP>
      <EVENTO_TECH></EVENTO_TECH>
      <TIPO_LEGAME></TIPO_LEGAME>
      <CONSEGNA></CONSEGNA>
      </ROW>
      </TABELLA>
      </asx:values>
      </asx:abap>
    my transformation is
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ROOT"></tt:root>
      <tt:root name="NETWORK"></tt:root>
      <tt:root name="OPERAZIONE"></tt:root>
      <tt:template>
      <abap>
        <values>
           <network>
               <tt:value ref="NETWORK"></tt:value>
           </network>
           <operazione>
               <tt:value ref="OPERAZIONE"></tt:value>
           </operazione>
           <tabella>
              <tt:loop ref=".ROOT" name="line">
                <mandt>
                  <tt:value ref="$line.mandt"></tt:value>
                </mandt>
                <network>
                  <tt:value ref="$line.network"></tt:value>
                </network>
                <OPERAZIONE>
                  <tt:value ref="$line.OPERAZIONE"></tt:value>
                </OPERAZIONE>
                <ID_ACT>
                  <tt:value ref="$line.ID_ACT"></tt:value>
                </ID_ACT>
                <DESC_ACT>
                  <tt:value ref="$line.DESC_ACT"></tt:value>
                </DESC_ACT>
                <LONG_TXT>
                  <tt:value ref="$line.LONG_TXT"></tt:value>
                </LONG_TXT>
                <MAKE_BUY>
                  <tt:value ref="$line.MAKE_BUY"></tt:value>
                </MAKE_BUY>
                <WP>
                  <tt:value ref="$line.WP"></tt:value>
                </WP>
                <EVENTO_TECH>
                  <tt:value ref="$line.EVENTO_TECH"></tt:value>
                </EVENTO_TECH>
                <TIPO_LEGAME>
                  <tt:value ref="$line.TIPO_LEGAME"></tt:value>
                </TIPO_LEGAME>
                <CONSEGNA>
                  <tt:value ref="$line.CONSEGNA"></tt:value>
                </CONSEGNA>
             </tt:loop>
            </tabella>
          </values>
        </abap>
      </tt:template>
    </tt:transform>
    when I execute my code
    the system dump with this error
    ST_MATCH_FAIL
    excep.  CX_ST_MATCH_ELEMENT
      TRY.
                CALL TRANSFORMATION ('ZT_NETWORK')
                SOURCE XML lv_xml_data_string
                RESULT  network = l_network
                        operazione = l_operazione
                        root = it_data_tmp.
              CATCH cx_sy_conversion_data_loss .
              CATCH cx_xslt_exception INTO xslt_error.
                xslt_message = xslt_error->get_text( ).
                WRITE:/ xslt_message .
            ENDTRY.
    Any help?
    thanks
    enzo

    Enzo Porcasi wrote:
    > I have a problem with a transformation from xml to abap. My XML file (taken from a pdf file) is
    >
    <?xml version="1.0" encoding="iso-8859-1" ?>
    >  <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    >  <asx:values>
    Your XML is strange, it looks like a mix of pdf form content (xfa) and identity transformation (asx).
    Could you explain more ?
    Anyway, I tried to find out the errors (not only cx_st_match_element, that was just a catch missing), it works with the following program. Here are the main issues I have found :
    - always catch exception class cx_st_error when you use simple transformations (it contains cx_st_match_element and all other simple transformation exceptions)
    - xml "asx:abap" and "asx:values" in your input XML are useless, they are only used by identity transformation ("ID"); you may keep them if you want, but I advise you to see why they are in the xml !
    - Use same case in your tags (if xml contains  in the transformation so that it corresponds to the input XML
    - I renamed all abap names with prefix ABAP_ so that to clearly differentiate xml tags and abap field names (so that it is more easy to understand, for every sdn reader; I hope it will help as I didn't find many threads in the forum).
    Simple transformation :
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="ABAP_NETWORK"></tt:root>
      <tt:root name="ABAP_OPERAZIONE"></tt:root>
      <tt:root name="ABAP_TABELLA"></tt:root>
      <tt:template>
        <ROOT>
          <NETWORK>
            <tt:value ref=".ABAP_NETWORK"></tt:value>
          </NETWORK>
          <OPERAZIONE>
            <tt:value ref=".ABAP_OPERAZIONE"></tt:value>
          </OPERAZIONE>
          <TABELLA>
            <tt:loop ref=".ABAP_TABELLA" name="line">
              <ROW>
                <MANDT>
                  <tt:value ref="$line.ABAP_MANDT"></tt:value>
                </MANDT>
                <NETWORK>
                  <tt:value ref="$line.ABAP_NETWORK"></tt:value>
                </NETWORK>
                <OPERAZIONE>
                  <tt:value ref="$line.ABAP_OPERAZIONE"></tt:value>
                </OPERAZIONE>
                <ID_ACT>
                  <tt:value ref="$line.ABAP_ID_ACT"></tt:value>
                </ID_ACT>
                <DESC_ACT>
                  <tt:value ref="$line.ABAP_DESC_ACT"></tt:value>
                </DESC_ACT>
                <LONG_TXT>
                  <tt:value ref="$line.ABAP_LONG_TXT"></tt:value>
                </LONG_TXT>
                <MAKE_BUY>
                  <tt:value ref="$line.ABAP_MAKE_BUY"></tt:value>
                </MAKE_BUY>
                <WP>
                  <tt:value ref="$line.ABAP_WP"></tt:value>
                </WP>
                <EVENTO_TECH>
                  <tt:value ref="$line.ABAP_EVENTO_TECH"></tt:value>
                </EVENTO_TECH>
                <TIPO_LEGAME>
                  <tt:value ref="$line.ABAP_TIPO_LEGAME"></tt:value>
                </TIPO_LEGAME>
                <CONSEGNA>
                  <tt:value ref="$line.ABAP_CONSEGNA"></tt:value>
                </CONSEGNA>
              </ROW>
            </tt:loop>
          </TABELLA>
        </ROOT>
      </tt:template>
    </tt:transform>
    Program and XML included :
    REPORT  zsro2.
    DATA l_network TYPE string.
    DATA l_operazione TYPE string.
    DATA : BEGIN OF lt_data_tmp OCCURS 0,
             abap_mandt      TYPE string,
             abap_network    TYPE string,
             abap_operazione TYPE string,
             abap_id_act     TYPE string,
             abap_desc_act   TYPE string,
             abap_long_txt   TYPE string,
             abap_make_buy   TYPE string,
             abap_wp         TYPE string,
             abap_evento_tech TYPE string,
             abap_tipo_legame TYPE string,
             abap_consegna   TYPE string,
           END OF lt_data_tmp.
    DATA xslt_error TYPE REF TO cx_xslt_exception.
    DATA lo_st_error TYPE REF TO cx_st_error.
    DATA lv_xml_data_string TYPE string.
    DATA xslt_message TYPE string.
    DEFINE conc.
      concatenate lv_xml_data_string &1 into lv_xml_data_string.
    END-OF-DEFINITION.
    *conc '<?xml version="1.0" encoding="iso-8859-1" ?>'.
    *conc '<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">'.
    *conc '  <asx:values>'.
    conc ' <ROOT>'.
    conc '    <NETWORK>E60000000000</NETWORK> '.
    conc '    <OPERAZIONE>0010</OPERAZIONE> '.
    conc '    <TABELLA>'.
    conc '      <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
    conc '        <MANDT>300</MANDT> '.
    conc '        <NETWORK>E60000000000</NETWORK> '.
    conc '        <OPERAZIONE>0010</OPERAZIONE> '.
    conc '        <ID_ACT>1</ID_ACT> '.
    conc '        <DESC_ACT>ATTIVITÀ1</DESC_ACT> '.
    conc '        <LONG_TXT></LONG_TXT> '.
    conc '        <MAKE_BUY></MAKE_BUY> '.
    conc '        <WP></WP> '.
    conc '        <EVENTO_TECH></EVENTO_TECH> '.
    conc '        <TIPO_LEGAME></TIPO_LEGAME> '.
    conc '        <CONSEGNA></CONSEGNA> '.
    conc '      </ROW>'.
    conc '      <ROW xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:dataNode="dataGroup">'.
    conc '        <MANDT>300</MANDT> '.
    conc '        <NETWORK>E60000000000</NETWORK> '.
    conc '        <OPERAZIONE>0010</OPERAZIONE> '.
    conc '        <ID_ACT>2</ID_ACT> '.
    conc '        <DESC_ACT>ATTIVITÀ2</DESC_ACT> '.
    conc '        <LONG_TXT>ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2 ATTIVITÀ2</LONG_TXT> '.
    conc '        <MAKE_BUY>M</MAKE_BUY> '.
    conc '        <WP></WP> '.
    conc '        <EVENTO_TECH></EVENTO_TECH> '.
    conc '        <TIPO_LEGAME></TIPO_LEGAME> '.
    conc '        <CONSEGNA></CONSEGNA> '.
    conc '      </ROW>'.
    conc '    </TABELLA>'.
    conc ' </ROOT>'.
    *conc '  </asx:values>'.
    *conc '</asx:abap>'.
    DATA lv_xml_data_string_2 TYPE string.
    TRY.
        CALL TRANSFORMATION zsro
              SOURCE
                XML lv_xml_data_string
              RESULT
                abap_network    = l_network
                abap_operazione = l_operazione
                abap_tabella    = lt_data_tmp[].
      CATCH cx_sy_conversion_data_loss .
      CATCH cx_st_error INTO lo_st_error.
        xslt_message = lo_st_error->get_text( ).
        WRITE:/ xslt_message .
      CATCH cx_xslt_exception INTO xslt_error.
        xslt_message = xslt_error->get_text( ).
        WRITE:/ xslt_message .
    ENDTRY.
    BREAK-POINT.

  • Creating XML transformation using multiple internal tables

    <b>Hi everyone,</b><br />
    <br />
    <b>I'm trying to transforme 3 internal tables (from customer master data) into a single XML document.</b><br />
    <p />
    DATA:   BEGIN OF wtab OCCURS 0 ,<br />
            kunnr LIKE kna1-kunnr, "Customer ID<br />
            ktokd LIKE kna1-ktokd, <br />
            land1 LIKE kna1-land1, <br />
            name1 LIKE kna1-name1, <br />
            ort01 LIKE kna1-ort01, <br />
            pstlz LIKE kna1-pstlz, <br />
            spras_iso LIKE kna1-spras, <br />
            smtp_addr LIKE adr6-smtp_addr, <br />
            stras LIKE kna1-stras, <br />
              END OF wtab.<br />
    <br />
    DATA:   BEGIN OF wtab_o OCCURS 0 ,<br />
            kunnr LIKE knvv-kunnr, "Customer ID<br />
            vkorg LIKE knvv-vkorg, "Sales organisation<br />
            waers LIKE knvv-waers, <br />
            END OF wtab_o.<br />
    <br />
    DATA:   BEGIN OF wtab_p OCCURS 0 ,<br />
            kunnr LIKE knvp-kunnr, "Customer ID<br />
            vkorg LIKE knvp-vkorg, "Sales organisation<br />
            parvw LIKE knvp-parvw, <br />
            kunn2 LIKE knvp-kunnr,<br />
              END OF wtab_p.<br />
    <p />
    <b>The internal tables are related to each other as follows:*</b><br />
    <br />
    wtab-kunnr = wtab_o-kunnr<br />
    <br />
    AND<br />
    <br />
    wtab_o-vkorg = wtab_p-vkorg<br />
    wtab_o-kunnr = wtab_p-kunnr<br />
    <br />
    <b>I couldn't figure out how to declare this relationship when calling the transformation. Is it possible?</b><br />
    <p />
    ABAP<br />
    <br />
    <br />
    REFRESH : gt_source_itab.<br />
    CLEAR : g_rxml.<br />
    <br />
      GET REFERENCE OF wtab INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'DEBMAS04'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
      GET REFERENCE OF wtab_o INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'E1KNVVM'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
    GET REFERENCE OF wtab_p INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'E1KNVPM'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
      TRY.<br />
          CALL TRANSFORMATION Z_XSLT_CLIENT<br />
          SOURCE (gt_source_itab)<br />
          RESULT XML g_rxml<br />
          OPTIONS xml_header = 'without_encoding'.<br />
    CATCH cx_root INTO gs_rif_ex.<br />
    <br />
          gs_var_text = gs_rif_ex-&gt;get_text( ).<br />
          MESSAGE gs_var_text TYPE 'E'.<br />
        ENDTRY.<br />
    <br />
    <br />
    Transformation Z_XSLT_CLIENT:<br />
    <br />
    <br />
    &lt;xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:sap="http://www.sap.com/sapxsl"&gt;<br />
    &lt;xsl:output indent="yes" encoding="UTF-16" method="xml" version="1.0"/&gt;<br />
    &lt;xsl:strip-space elements="*"/&gt;<br />
    &lt;xsl:template match="/"&gt;<br />
    &lt;DEBMAS04&gt;<br />
    &lt;xsl:apply-templates select="//DEBMAS04/item"/&gt;<br />
    &lt;/DEBMAS04&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="DEBMAS04/item"&gt;<br />
         &lt;IDOC&gt;<br />
           &lt;xsl:attribute name="BEGIN"&gt;1&lt;/xsl:attribute&gt;<br />
           &lt;E1KNA1M&gt;<br />
            &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
            &lt;KUNNR&gt;<br />
               &lt;xsl:value-of select="KUNNR"/&gt;<br />
            &lt;/KUNNR&gt;<br />
            &lt;KTOKD&gt;<br />
               &lt;xsl:value-of select="KTOKD"/&gt;<br />
            &lt;/KTOKD&gt;<br />
            &lt;LAND1&gt;<br />
               &lt;xsl:value-of select="LAND1"/&gt;<br />
            &lt;/LAND1&gt;<br />
            &lt;NAME1&gt;<br />
               &lt;xsl:value-of select="NAME1"/&gt;<br />
            &lt;/NAME1&gt;<br />
            &lt;ORT01&gt;<br />
               &lt;xsl:value-of select="ORT01"/&gt;<br />
            &lt;/ORT01&gt;<br />
            &lt;PSTLZ&gt;<br />
               &lt;xsl:value-of select="PSTLZ"/&gt;<br />
            &lt;/PSTLZ&gt;<br />
            &lt;SPRAS_ISO&gt;<br />
               &lt;xsl:value-of select="SPRAS_ISO"/&gt;<br />
            &lt;/SPRAS_ISO&gt;<br />
            &lt;SMTP_ADDR&gt;<br />
               &lt;xsl:value-of select="SMTP_ADDR"/&gt;<br />
            &lt;/SMTP_ADDR&gt;<br />
            &lt;STRAS&gt;<br />
               &lt;xsl:value-of select="STRAS"/&gt;<br />
            &lt;/STRAS&gt;<br />
             &lt;xsl:apply-templates select="//E1KNVVM/item"/&gt;<br />
           &lt;/E1KNA1M&gt;<br />
      &lt;/IDOC&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="E1KNVVM/item"&gt;<br />
       &lt;E1KNVVM&gt;<br />
             &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
             &lt;VKORG&gt;<br />
               &lt;xsl:value-of select="VKORG"/&gt;<br />
             &lt;/VKORG&gt;<br />
             &lt;WAERS&gt;<br />
               &lt;xsl:value-of select="WAERS"/&gt;<br />
             &lt;/WAERS&gt;<br />
           &lt;xsl:apply-templates select="//E1KNVPM/item"/&gt;<br />
       &lt;/E1KNVVM&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="E1KNVPM/item"&gt;<br />
       &lt;E1KNVPM&gt;<br />
             &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
             &lt;PARVW&gt;<br />
               &lt;xsl:value-of select="PARVW"/&gt;<br />
             &lt;/PARVW&gt;<br />
             &lt;KUNN2&gt;<br />
               &lt;xsl:value-of select="KUNN2"/&gt;<br />
             &lt;/KUNN2&gt;<br />
       &lt;/E1KNVPM&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;/xsl:transform&gt;<br />
    <br />
    <b>The way the call transformation is now, for each line in table wtab (DEBMAS04) I'm getting all the lines in table wtab_o (E1KNVVM) and table wtab_p (E1KNVPM)</b><br />
    <p />
    <br />
    Thank you for your help,<br />
    <br />
    Giselle<br />
    <p />

    Hi Giselle,
    I think it's possible (using xsl:if for instance), but an easier way is to nest your internal tables declarations (wtab_o inside wtab, kunnr becomes useless, and wtab_p inside wtab_o), and use the SAP standard "ID" transformation (no need for a custom XSL transformation). You'll get a slightly different result, but I don't think you want something very sophisticated.
    Sandra

  • Upload XML to internal table and vice versa in SAP 4.6C

    Hi,
       Happy New Year to you all!
       We are using 46C and I am beginning to learn about XML. We have a requirement to (1) upload an XML file into an internal table as well as (2) create an XML file from an internal table.
       I read some of the posted messages about this but they didn't seem to be applicable in 46C (I could be wrong).
       Could someone please help me using the sample file below?
      <?xml version="1.0" ?>
    - <AUCTIONBLOCK>
    - <ITEM>
      <TITLE>Still Life / Onions</TITLE>
      <ARTIST>Linda Mann</ARTIST>
      <DIMENSIONS>20x30 inches</DIMENSIONS>
      <MATERIALS>Oil</MATERIALS>
      <YEAR>1997</YEAR>
      <DESCRIPTION>Still Life</DESCRIPTION>
      <TIMESTAMP>1974</TIMESTAMP>
      </ITEM>
      </AUCTIONBLOCK>
    Many thanks,
    Rosemarie

    Hi,
    Yes I'm on 4.6c. I've to comment several lines. Here is an example:
    *& Report  z_xit_xml_check
      report  z_xit_xml_check.
      class cl_ixml definition load.
      type-pools: ixml.
      types: begin of t_xml_line,
              data(256) type x,
            end of t_xml_line,
            begin of tsfixml,
              data(1024) type c,
            end of tsfixml.
      data: l_ixml            type ref to if_ixml,
            l_streamfactory   type ref to if_ixml_stream_factory,
            l_parser          type ref to if_ixml_parser,
            l_istream         type ref to if_ixml_istream,
            l_document        type ref to if_ixml_document,
            l_node            type ref to if_ixml_node,
            l_xmldata         type string.
      data: l_elem            type ref to if_ixml_element,
            l_root_node       type ref to if_ixml_node,
            l_next_node       type ref to if_ixml_node,
            l_name            type string,
            l_iterator        type ref to if_ixml_node_iterator.
      data: l_xml_table       type table of t_xml_line,
            l_xml_line        type t_xml_line,
            l_xml_table_size  type i.
      data: l_filename        type string.
      parameters: pa_file type char1024 default
      'd:joaodesenvolvimentos i act     este.xml'.
    Validation of XML file: Only DTD included in xml document is supported
      parameters: pa_val  type char1 as checkbox.
      start-of-selection.
      Creating the main iXML factory
        l_ixml = cl_ixml=>create( ).
      Creating a stream factory
        l_streamfactory = l_ixml->create_stream_factory( ).
    Regards,
    Maria João Rocha
        perform get_xml_table changing l_xml_table_size l_xml_table.
      wrap the table containing the file into a stream
        l_istream = l_streamfactory->create_istream_itable( table =
    l_xml_table
                                                        size  =
    l_xml_table_size ).
      Creating a document
        l_document = l_ixml->create_document( ).
      Create a Parser
        l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
                                          istream        = l_istream
                                          document       = l_document ).
      Validate a document
        if pa_val eq 'X'.
       l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
        endif.
      Parse the stream
        if l_parser->parse( ) ne 0.
          if l_parser->num_errors( ) ne 0.
            data: parseerror type ref to if_ixml_parse_error,
                  str        type string,
                  i          type i,
                  count      type i,
                  index      type i.
            count = l_parser->num_errors( ).
            write: count, ' parse errors have occured:'.
            index = 0.
            while index < count.
              parseerror = l_parser->get_error( index = index ).
              i = parseerror->get_line( ).
              write: 'line: ', i.
              i = parseerror->get_column( ).
              write: 'column: ', i.
              str = parseerror->get_reason( ).
              write: str.
              index = index + 1.
            endwhile.
          endif.
        endif.
      Process the document
        if l_parser->is_dom_generating( ) eq 'X'.
          perform process_dom using l_document.
        endif.
    *&      Form  get_xml_table
      form get_xml_table changing l_xml_table_size type i
                                  l_xml_table      type standard table.
      Local variable declaration
        data: l_len      type i,
              l_len2     type i,
              l_tab      type tsfixml,
              l_content  type string,
              l_str1     type string,
            c_conv     TYPE REF TO cl_abap_conv_in_ce,
              l_itab     type table of string.
        l_filename = pa_file.
      upload a file from the client's workstation
        call method cl_gui_frontend_services=>gui_upload
          exporting
            filename   = l_filename
            filetype   = 'BIN'
          importing
            filelength = l_xml_table_size
          changing
            data_tab   = l_xml_table
          exceptions
            others     = 19.
        if sy-subrc <> 0.
          message id sy-msgid type sy-msgty number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
      Writing the XML document to the screen
       CLEAR l_str1.
       LOOP AT l_xml_table INTO l_xml_line.
         c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
    *replacement = space  ).
         c_conv->read( IMPORTING data = l_content len = l_len ).
         CONCATENATE l_str1 l_content INTO l_str1.
       ENDLOOP.
       l_str1 = l_str1+0(l_xml_table_size).
       SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
       WRITE: /.
       WRITE: /' XML File'.
       WRITE: /.
       LOOP AT l_itab INTO l_str1.
         REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
    *IN
           l_str1 WITH space.
         WRITE: / l_str1.
       ENDLOOP.
       WRITE: /.
      endform.                    "get_xml_table
    *&      Form  process_dom
      form process_dom using document type ref to if_ixml_document.
        data: node      type ref to if_ixml_node,
              iterator  type ref to if_ixml_node_iterator,
              nodemap   type ref to if_ixml_named_node_map,
              attr      type ref to if_ixml_node,
              name      type string,
              prefix    type string,
              value     type string,
              indent    type i,
              count     type i,
              index     type i.
    data: name2 type string,
          name_root type string,
          node_parent      type ref to if_ixml_node,
          node_root        type ref to if_ixml_node,
          num_children     type i.
        node ?= document.
        check not node is initial.
        uline.
        write: /.
        write: /' DOM-TREE'.
        write: /.
        if node is initial. exit. endif.
      create a node iterator
        iterator  = node->create_iterator( ).
      get current node
        node = iterator->get_next( ).
      loop over all nodes
        while not node is initial.
          indent = node->get_height( ) * 2.
          indent = indent + 20.
    num_children = node->num_children( ).
          case node->get_type( ).
            when if_ixml_node=>co_node_element.
            element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
              node_root = node->get_root( ).
              name_root = node_root->get_name( ).
                        write: / 'ELEMENT  :'.
              write: at indent name color col_positive inverse.
              write: 'NUM_CHILDREN:', num_children.
              write: 'ROOT:', name_root.
              node_parent = node->get_parent( ).
              name2    = node_parent->get_name( ).
              write: 'NAME2: ' , name2.
              if not nodemap is initial.
              attributes
                count = nodemap->get_length( ).
                do count times.
                  index  = sy-index - 1.
                  attr   = nodemap->get_item( index ).
                  name   = attr->get_name( ).
                prefix = attr->get_namespace_prefix( ).
                  value  = attr->get_value( ).
                  write: / 'ATTRIBUTE:'.
                  write: at indent name  color col_heading inverse, '=',
                                   value color col_total   inverse.
                enddo.
              endif.
            when if_ixml_node=>co_node_text or
                 if_ixml_node=>co_node_cdata_section.
            text node
              value  = node->get_value( ).
              write: / 'VALUE     :'.
    mjprocha
              node_parent = node->get_parent( ).
              write: at indent value color col_group inverse.
              name2    = node_parent->get_name( ).
              write: 'NAME2: ' , name2.
          endcase.
        advance to next node
          node = iterator->get_next( ).
        endwhile.
      endform.                    "process_dom

  • Simple Transformation XML to ABAP Content of tag with subtrees to string field

    Hi,
    I have an  requirement in which I have to do a transformation from an XML file to an structure.
    I need get the value of a tag that have subtrees and move that to a field in my structure.
    Example:
    <TAG1>value1</TAG1>
    <TAG2>value2</TAG2>
    <TAG3>
         <TAG4>value4</TAG4>
         <TAG5>value5</TAG5>
    </TAG3>
    Result expected in ABAP Structure:
    field1 -> tag1
    field2 -> tag2
    field3 -> <TAG4>value4</TAG4><TAG5>value5</TAG5>
    The contents of the tag TAG3 is variable, so I want to store it as a string.
    Can I make this with Simple Transformation?
    In my tests I can move only the value of each child tag for the given field structure.
    This syntax dont work:
    <TAG3 tt:value-ref="STRUCTURE.FIELD3"/>
    Thanks and Regards,
    Miguel Motta

    Hi Miguel
    Have a look at below snippets. Here I have tried to escape the text inside TAG3 so that it gets treated as single node during transformation.
    ABAP code
    DATA: BEGIN OF result,
            col1 TYPE string,
            col2 TYPE string,
            col3 TYPE string,
          END OF result.
    DATA: xml_string TYPE string VALUE
    '<ROOT> <TAG1>value1</TAG1> <TAG2>value2</TAG2> <TAG3> <TAG4>value4</TAG4> <TAG5>value5</TAG5> </TAG3> </ROOT>',
          part1 TYPE string,
          part2 TYPE string,
          part3 TYPE string.
    *   Escape the text inside TAG3 tag
    FIND REGEX '(.*<TAG3>)(.*)(</TAG3>.*)' IN xml_string SUBMATCHES part1 part2 part3.
    IF sy-subrc EQ 0.
      part2 = escape( val = part2 format = cl_abap_format=>e_xml_text ).
    *      REPLACE ALL OCCURRENCES OF '<' IN part2 WITH '&lt;'.
    *      REPLACE ALL OCCURRENCES OF '>' IN part2 WITH '&gt;'.
      xml_string = part1 && part2 && part3.
    ENDIF.
    TRY.
    * Display xml
        cl_abap_browser=>show_xml( EXPORTING xml_string = xml_string ).
    * Deserialization
        CALL TRANSFORMATION zmtest
          SOURCE XML xml_string
          RESULT para = result.
    * Check result
        WRITE:/ 'COL1=', result-col1,
              / 'COL2=', result-col2,
              / 'COL3=', result-col3.
      CATCH cx_st_error.
    * Error handling
        MESSAGE 'Error in Simple Transformation'
                TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.
    Transformation code
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates" template="temp" version="0.1">
       <tt:root name="PARA"/>
       <tt:template name="temp">
         <ROOT>
           <TAG1>
             <tt:value ref="PARA.COL1"/>
           </TAG1>
           <TAG2>
             <tt:value ref="PARA.COL2"/>
           </TAG2>
           <TAG3>
             <tt:value ref="PARA.COL3"/>
           </TAG3>
         </ROOT>
       </tt:template>
    </tt:transform>

  • XML to internal table conversion within ABAP mapping class

    I am doing a ABAP mapping for file to Idoc. My requirement is to convert XML file into ABAP internal table (within ABAP mapping class). Is there any standard FM, method, transformation etc, which can be used here.
    Thanks, Dehra

    Dehra,
    Have you seen this weblogs which talks about this:
    /people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
    /people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
    /people/r.eijpe/blog/2006/02/19/xml-dom-processing-in-abap-part-iiia150-xml-dom-within-sap-xi-abap-mapping
    /people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping
    Hope this helps you....
    ---Satish

  • XML to internal table

    Hi,
    I  am on 4.6 C. Call Transformation is not available here.
    I have an XML file with deep structure  with nodes/subnodes.
    I have to convert the file to an internal table with matching deep structure.
    I have seen a program that works in reverse- i.e. converts internal table with deep structure to XML and it seems to work fine in 4.6 C.
    Does anybody have a program that creates internal table from XML?
    Any help would be highly appreciated

    Hi,
    Please try to use FM SMUM_XML_PARSE.
    This FM will upload an XMl file into an internal table.
    Regards,
    Ferry Lianto

  • Help needed XML to Internal table and vice versa

    Hello frnds, I need to convert Internal table to XML and Vice versa.
    Now I am able to most of the part except for this...
    the xml which I have to generate looks something like this...
    - <trade_dt>
    - <![CDATA[ 20111108000000:20111108235959
      ]]>
      </trade_dt>
    its a range I think
    And then the reponse which I get back the XML is like
    - <lockinfo>
    - <![CDATA[
    TRD_HEADER     1045     1          2
    ACT_CASHFLOW     1042               1
    TRD_TERM     1045               2
      ]]>
      </lockinfo>
    Is there any provision in class cl_ixml or class if_ixml_element to handle this part.....
    Edited by: Amit Sawant on Dec 28, 2011 3:51 PM

    Hello Amit,
    I would suggest you, to use the XSL-Transformations, which can be inbound used in ABAP.
    For example:
    DATA:
      l_xml       TYPE string,
      lt_flights  TYPE TABLE OF SFLIGHT.
    SELECT * FROM SFLIGHT INTO TABLE LT_FLIGHT.
    CALL TRANSFORMATION id
      SOURCE DATA = lt_flights
      RESULT XML l_xml.
    Now, you have a XML-String which is in the ABAP-XML Notation, which means, that ABAP can move this XML-Data back into an internal table/structure.
    For the backward, you have to use the following statement:
    CALL TRANSFORMATION id
      SOURCE XML l_xml
      RESULT DATA = lt_flights.
    As you will see, it is very easy. The Transformation "id" is just one example and build in. When you have to transform the data, or do not want to have the ASX-Notation in it, you should at least define your own transformations with the transaction XSLT_TOOL and use it similar to the transformation "id".
    Kind Regards,
    Hendrik

  • How to parse XML for internal table

    hi guys, I would like to know how to parse xml for an internal table. I explain myself.
    Let's say you have a purchase order form where you have header data & items data. In my interactive form, the user can change the purchase order quantity at the item level. When I received back the pdf completed by mail, I need to parse the xml and get the po qty that has been entered.
    This is how I do to get header data from my form
    lr_ixml_node = lr_ixml_document->find_from_name( name = ''EBELN ).
    lv_ebeln = lr_ixml_node->get_value( ).
    How do we do to get the table body??
    Should I used the same method (find_from_name) and passing the depth parameter inside a do/enddo?
    thanks
    Alexandre Giguere

    Alexandre,
    Here is an example. Suppose your internal table is called 'ITEMS'.
    lr_node = lr_document->find_from_name('ITEMS').
    lv_num_of_children = lr_node->num_children( ).
    lr_nodechild = lr_node->get_first_child( ).
    do lv_num_of_children times.
        lv_num_of_attributes = lr_nodechild->num_children( ).
        lr_childchild = lr_nodechild->get_first_child( ).
       do lv_num_of_attributes times.
          lv_value = lr_childchild->get_value( ).
          case sy-index.
             when 1.
               wa_item-field1 = lv_value
             when 2.
               wa_item-field2 = lv_value.
          endcase.
          lr_childchild = lr_childchild->get_next( ).
       enddo.
       append wa_item to lt_item.
       lr_nodechild = lr_nodechild->get_next( ).
    enddo.

Maybe you are looking for