Skip to Content
author's profile photo Former Member
Former Member

XML to internal data transfer

Hi all,

I am trying to data transfer XML file to abap internal table.

How to take internal table contants. please help me.

Below XML file............

............................................................................................

<?xml version="1.0" encoding="UTF-8" ?>

<?Siebel-Property-Set EscapeNames="false"?>

- <SiebelMessage MessageId="1-1HNFO" IntObjectName="SAP 4x Order - Create SAP Order (BAPI Input)" MessageType="Integration Object" IntObjectFormat="Siebel Hierarchical">

- <ListOfBapi_Salesorder_Createfromdat1_Sgarg>

- <ImportParameters>

<CONVERT_PARVW_AUART>X</CONVERT_PARVW_AUART>

<ORDER_HEADER_IN-DOC_TYPE>ZVOR</ORDER_HEADER_IN-DOC_TYPE>

<ORDER_HEADER_IN-SALES_ORG>PSPR</ORDER_HEADER_IN-SALES_ORG>

<ORDER_HEADER_IN-DISTR_CHAN>DL</ORDER_HEADER_IN-DISTR_CHAN>

<ORDER_HEADER_IN-DIVISION>01</ORDER_HEADER_IN-DIVISION>

<ORDER_HEADER_IN-SALES_GRP />

<ORDER_HEADER_IN-SALES_OFF>PUNE</ORDER_HEADER_IN-SALES_OFF>

<ORDER_HEADER_IN-PURCH_NO>IK020809PPO00310</ORDER_HEADER_IN-PURCH_NO>

<ORDER_HEADER_IN-PURCH_DATE>08/19/2008 10:55:57</ORDER_HEADER_IN-PURCH_DATE>

<ORDER_HEADER_IN-SHIP_COND>12</ORDER_HEADER_IN-SHIP_COND>

<WITHOUT_COMMIT />

- <ListOfORDER_ITEMS_IN>

- <ORDER_ITEMS_IN>

<PO_ITM_NO>1</PO_ITM_NO>

<MATERIAL>A21176635069999</MATERIAL>

<REQ_QTY>2</REQ_QTY>

<ALTERN_BOM>1-1C1QW7</ALTERN_BOM>

</ORDER_ITEMS_IN>

- <ORDER_ITEMS_IN>

<PO_ITM_NO>2</PO_ITM_NO>

<MATERIAL>A2037665006</MATERIAL>

<REQ_QTY>2</REQ_QTY>

<ALTERN_BOM>1-1C1QW7</ALTERN_BOM>

</ORDER_ITEMS_IN>

</ListOfORDER_ITEMS_IN>

- <ListOfORDER_PARTNERS>

- <ORDER_PARTNERS>

<PARTN_ROLE>SP</PARTN_ROLE>

<PARTN_NUMB>0000002649</PARTN_NUMB>

</ORDER_PARTNERS>

- <ORDER_PARTNERS>

<PARTN_ROLE>SH</PARTN_ROLE>

<PARTN_NUMB>0000002649</PARTN_NUMB>

</ORDER_PARTNERS>

</ListOfORDER_PARTNERS>

</ImportParameters>

</ListOfBapi_Salesorder_Createfromdat1_Sgarg>

</SiebelMessage>

Thanks

SReddy.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 21, 2008 at 10:43 AM

    Hi,

    1. read the xml file into a string

    2. convert the string to xstring using SCMS_STRING_TO_XSTRING

    3. now use FM SMUM_XML_PARSE and pass the xstring xml_input parameter of that function.

    this will parse the whole xml and give you an itab of element name value pairs which you can read easily.

    Regards,

    Karol

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 21, 2008 at 07:00 PM

    Hello Reddy

    The fm's proposed by Karol are straightforward to use (see sample report ZUS_SDN_XML_TO_ABAP_1 ).

    There may be other approaches to parse the XML yet for your purpose it seems to be quite useful.

    *&---------------------------------------------------------------------*
    *& Report  ZUS_SDN_XML_TO_ABAP_1
    *&
    *&---------------------------------------------------------------------*
    *& Thread: XML to internal data transfer
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1055170"></a>
    *&---------------------------------------------------------------------*
    
    REPORT  zus_sdn_xml_to_abap_1.
    
    TYPE-POOLS: abap.
    
    DATA: go_xml_doc      TYPE REF TO cl_xml_document,
          gd_rc           TYPE i.
    
    DATA: gt_xmldata      TYPE TABLE OF string,
          gd_xmldata      TYPE string,
          gd_xstring      TYPE xstring.
    
    DATA: gt_xml_tab      TYPE STANDARD TABLE OF smum_xmltb,
          gt_return       TYPE bapirettab,
          gs_layout       TYPE lvc_s_layo.
    
    
    PARAMETERS:
      p_file    TYPE localfile  DEFAULT 'C:	empsiebel_create_so.xml'.
    
    
    START-OF-SELECTION.
    
      CREATE OBJECT go_xml_doc.
      CALL METHOD go_xml_doc->import_from_file
        EXPORTING
          filename = p_file
        RECEIVING
          retcode  = gd_rc.
    
      CALL METHOD go_xml_doc->render_2_string
    *    EXPORTING
    *      pretty_print = 'X'
        IMPORTING
          retcode      = gd_rc
          stream       = gd_xmldata
    *      size         =
          .
    
    
    
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text           = gd_xmldata
    *     MIMETYPE       = ' '
    *     ENCODING       =
        IMPORTING
          buffer         = gd_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.
    
    
      CALL FUNCTION 'SMUM_XML_PARSE'
        EXPORTING
          xml_input = gd_xstring
        TABLES
          xml_table = gt_xml_tab
          return    = gt_return.
    
      gs_layout-cwidth_opt = abap_true.
      gs_layout-zebra      = abap_true.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          i_structure_name = 'SMUM_XMLTB'
          is_layout_lvc    = gs_layout
        TABLES
          t_outtab         = gt_xml_tab
        EXCEPTIONS
          program_error    = 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.
    
    
    END-OF-SELECTION.
    

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.