XML to Internal tables

Hi,
Our scenairo is to retreive the data from XML file and convert it into Idoc for inbound processing.
I need to get the data from xml to the internal tables so that i can convert them to idoc through Function Modules.
My issue is XML file is not fixed nor the message type and the idoc type. Everything is dynamic.
I am currently tryin by creating dynamic internal table but i think i need to create multiple dynamic tables from a dynamic table.
Please suggest the path forward.
Thanks,
Varun

hi,
check the below code.
this will convert XML data into an internal table. From this internal table u can manipulate and get desired results.
*Generated from XML file (upload)
    CALL METHOD xml->import_from_file
      EXPORTING
        filename = p_file
      RECEIVING
        retcode  = ret.
*convert to string
    CALL METHOD xml->render_2_string
      IMPORTING
        retcode      = ret
        stream       = stream
       size         =
*convert to xstring
    CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
      EXPORTING
        text   = stream
      IMPORTING
        buffer = xstring
      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.
*Extract data from xsting to internal table
    CALL FUNCTION 'SMUM_XML_PARSE'
      EXPORTING
        xml_input = xstring
      TABLES
        xml_table = it_data
        return    = it_ret.
Regards,
Aswin.

Similar Messages

  • 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

  • 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

  • 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

  • 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

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

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

  • 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

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

  • Xml to internal table using XSLT

    hello all,
    With the help of Mr. raja I have done with  the code but still i have some problem. could any one help me(raja you too).
    XLST program code (YSIMPLEXMLTOITAB)
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:output indent="yes"/>
      <xsl:template match="QfiData">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml">
          <asx:values>
            <I_DATA>
              <xsl:for-each select="Materials">
                <I_DATA1>
                  <MATERIAL>
                    <xsl:value-of select="Material"/>
                  </MATERIAL>
                  <CONDITIONRATE>
                    <xsl:value-of select="ConditionRate"/>
                  </CONDITIONRATE>
                  <VALIDFROM>
                    <xsl:value-of select="ValidFrom"/>
                  </VALIDFROM>
                  <VALIDTO>
                    <xsl:value-of select="ValidTo"/>
                  </VALIDTO>
                  <REGIONID>
                    <xsl:value-of select="RegionID"/>
                  </REGIONID>
                  <MATERIALID>
                    <xsl:value-of select="MaterialID"/>
                  </MATERIALID>
                </I_DATA1>
              </xsl:for-each>
            </I_DATA>
          </asx:values>
        </asx:abap>
      </xsl:template>
    </xsl:stylesheet>
    Program to test it.
    REPORT  y_test_xml_tran.
    TYPES: BEGIN OF i_det,
    Material(10),
    ConditionRate(16) type p decimals 2 ,
    ValidFrom(10) ,
    ValidTo(10) ,
    RegionID(3) ,
    MaterialID(10) ,
    end of i_det .
    DATA: i_data TYPE TABLE OF i_det.
    data: wa like line of i_data .
    DATA: xml_string TYPE string .
    DATA: xslt_error     TYPE REF TO     cx_xslt_exception,
    xslt_message     TYPE     string .
    CLEAR xml_string .
    CONCATENATE
    `<?xml version="1.0" encoding="utf-8"?>`
    `<QfiData xmlns:xsl="http://www2.siemens.nl/qfiservice/QfiData.xsd">`
    `<Materials>`
    `<Material>463581</Material>`
    `<ConditionRate> 2.44</ConditionRate>`
    `<ValidFrom>20060208</ValidFrom>`
    `<ValidTo>99991231</ValidTo>`
    `<RegionID>48</RegionID>`
    `<MaterialID>36294</MaterialID>`
    `</Materials>`
    `<Materials>`
    `<Material>463582</Material>`
    `<ConditionRate> 2.44</ConditionRate>`
    `<ValidFrom>20060208</ValidFrom>`
    `<ValidTo>99991231</ValidTo>`
    `<RegionID>48</RegionID>`
    `<MaterialID>36295</MaterialID>`
    `</Materials>`
    `</QfiData>`
    INTO xml_string .
    TRY .
        CALL TRANSFORMATION (`YSIMPLEXMLTOITAB`)
        SOURCE XML  xml_string
        RESULT     i_data = i_data.
      CATCH cx_xslt_exception INTO xslt_error.
        xslt_message = xslt_error->get_text( ).
    ENDTRY.
    the error i am getting is:
    Error message : ABAP XML formatting error in XML node of type "element", name: "abap"

    Can you tell how did you solve ?

  • Issue with uploading XML file from application server into internal table

    i Need to fetch the XML file from the application server and place into internal table and i am getting error message while using the functional module   SMUM_XML_PARSE and the error message is "line   1 col   1-unexpected symbol; expected '<', '</', entity reference, character data, CDATA section, processing instruction or comment" and could you please let me know how to resolve this issue?  
        TYPES: BEGIN OF T_XML,
                 raw(2000) TYPE C,
               END OF T_XML.
    DATA:GW_XML_TAB TYPE  T_XML.
    DATA:  GI_XML_TAB TYPE TABLE OF T_XML INITIAL SIZE 0.
    DATA:GI_STR TYPE STRING.
    data:  GV_XML_STRING TYPE XSTRING.
    DATA: GI_XML_DATA TYPE  TABLE OF SMUM_XMLTB INITIAL SIZE 0.
    data:GI_RETURN TYPE STANDARD TABLE OF BAPIRET2.
        OPEN DATASET LV_FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF SY-SUBRC NE 0.
          MESSAGE 'File does not exist' TYPE 'E'.
        ELSE.
          DO.
    * Transfer the contents from the file to the work area of the internal table
            READ DATASET LV_FILE1 INTO GW_XML_TAB.
            IF SY-SUBRC EQ 0.
              CONDENSE GW_XML_TAB.
    *       Append the contents of the work area to the internal table
              APPEND GW_XML_TAB TO GI_XML_TAB.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
        ENDIF.
    * Close the file after reading the data
        CLOSE DATASET LV_FILE1.
        IF NOT GI_XML_TAB IS INITIAL.
          CONCATENATE LINES OF GI_XML_TAB INTO GI_STR SEPARATED BY SPACE.
        ENDIF.
    * The function module is used to convert string to xstring
        CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
          EXPORTING
            TEXT   = GI_STR
          IMPORTING
            BUFFER = GV_XML_STRING
          EXCEPTIONS
            FAILED = 1
            OTHERS = 2.
        IF SY-SUBRC <> 0.
          MESSAGE 'Error in the XML file' TYPE 'E'.
        ENDIF.
      ENDIF.
      IF GV_SUBRC = 0.
    * Convert XML to internal table
        CALL FUNCTION 'SMUM_XML_PARSE'
          EXPORTING
            XML_INPUT = GV_XML_STRING
          TABLES
            XML_TABLE = GI_XML_DATA
            RETURN    = GI_RETURN.
      ENDIF.
      READ TABLE GI_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
      IF SY-SUBRC EQ 0.
        MESSAGE 'Error converting the input XML file' TYPE 'E'.
      ELSE.
        DELETE GI_XML_DATA WHERE TYPE <> 'V'.
        REFRESH GI_RETURN.
      ENDIF.

    Could you please tel me  why the first 8 lines were removed, till <Soap:Body and also added the line <?xml version="1.0" encoding="UTF-8"?> in the beggining .
    Becuase there will be lot of  XML files will be coming from the Vendor daily and that should be uploaded in the application server and should update in the SAP tables based on the data in the XML file.
    what information i need to give to vendor that do not add the first 8 lines in the XML file and add the line in the beggining <?xml version="1.0" encoding="UTF-8"?>   ??????
    Is there any other way we can do with out removing the lines?

  • Create XML file from internal table and vise a versa

    Hi Friends,
    I have requirement to create an XML string from internal table data and also read XML string data to internal table.
    Can anybody tell are there any Function Modules or methods existing for this?
    Thanks.
    Krishna Yerram.

    1. Write XSLT program. T.code XSLT . e.g. XSLT name "ZTRANS".
    2. Write ABAP program
    Which includes declaration of internal tables
    that you need "IT_DATA".
    Upload XML data to an internal table "IT_XML "
    use below statement to convert XML to internal table.
    Call transformation ZTRANS
    source XML IT_XML
    result IT_DATA.

Maybe you are looking for

  • How can I play music I purchased with another apple id

    My AppleID has always been my email address.  I had to change it about a year ago and now I can't access anything I purchased from the iTunes store with that ID.  How do I get my music I paid for?

  • Is there anyway to recover synced over songs?

    I bought the new iphone 5 the other day and went to sync my old iphone 4 to my new computer. I received a new laptop because the old one fried... losing all my itunes content. I foolishly thought that if I downloaded itunes onto my new laptop and plu

  • Installing OMB Plus in Oracle JDeveloper

    Hello I have JDeveloper 11.1.1.3.0, and I like to enable the IDE for OMBPlus development. I followed the guide at http://download.oracle.com/docs/cd/B28359_01/owb.111/b31279.pdf (appendix Installing OMB Plus in Oracle JDeveloper) 1. Drop shiphome/owb

  • Go URL && SQL through POST-method

    Hello! To create reports, I use asynchronous queries like this (GET-method): saw.dll?Go&SQL=select+Region,Dollars+from+SupplierSales&format=xml But sometimes there are queries for which the length of the URL is too long. In this case I want to use th

  • How Do I Remove  Scanner from the Import Menu

    The printer has already been uninstalled from the computer and I do not see it listed in the Device Manager. Is there a configuration file somewere in the Photoshop application or program folders that I can edit to remove an old non-existent scanner