How to convert xml file into internal table in ABAP Mapping.

Hi All,
I am trying with ABAP mapping. I have one scenario in which I'm using below xml file as a sender from my FTP server.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:MTO_ABAP_MAPPING xmlns:ns0="http://Capgemini/Mumbai/sarsingh">
  <BookingCode>2KY34R</BookingCode>
- <Passenger>
  <Name>SARVESH</Name>
  <Address>THANE</Address>
  </Passenger>
- <Passenger>
  <Name>RAJESH</Name>
  <Address>POWAI</Address>
  </Passenger>
- <Passenger>
  <Name>CARRON</Name>
  <Address>JUHU</Address>
  </Passenger>
- <Flight>
  <Date>03/03/07</Date>
  <AirlineID>UA</AirlineID>
  <FlightNumber>125</FlightNumber>
  <From>LAS</From>
  <To>SFO</To>
  </Flight>
  </ns0:MTO_ABAP_MAPPING>
AT the receiver side I wnat to concatenate the NAME & ADDRESS.
I tried Robert Eijpe's weblog (/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)
but couldnt succeed to convert the xml file into internal table perfectly.
Can anybody help on this. 
Thanks in advance!!
Sarvesh

Hi Sarvesh,
The pdf has details of ABAP mapping. The example given almost matches the xml file you want to be converted.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how to use abap-mapping in xi 3.0.pdf
Just in case you have not seen this
regards
Vijaya

Similar Messages

  • How to Download XML File to internal table

    Hi Friends,
    This is my urgent requirement. How to download XML File to Internal table.
    regards
    pauldharma

    Hai,
    Please check this Link
    http://www.sap-img.com/abap/upload-direct-excel.htm
    PARAMETERS: filename LIKE rlgrap-filename MEMORY ID M01,
                begcol TYPE i DEFAULT 1 NO-DISPLAY,
                begrow TYPE i DEFAULT 1 NO-DISPLAY,
                endcol TYPE i DEFAULT 100 NO-DISPLAY,
                endrow TYPE i DEFAULT 32000 NO-DISPLAY.
    * Tick don't append header
    PARAMETERS: kzheader AS CHECKBOX.
    DATA: BEGIN OF intern OCCURS 0.
            INCLUDE STRUCTURE  alsmex_tabline.
    DATA: END OF intern.
    DATA: BEGIN OF intern1 OCCURS 0.
            INCLUDE STRUCTURE  alsmex_tabline.
    DATA: END OF intern1.
    DATA: BEGIN OF t_col OCCURS 0,
           col LIKE alsmex_tabline-col,
           size TYPE i.
    DATA: END OF t_col.
    DATA: zwlen TYPE i,
          zwlines TYPE i.
    DATA: BEGIN OF fieldnames OCCURS 3,
            title(60),
            table(6),
            field(10),
            kz(1),
          END OF fieldnames.
    * No of columns
    DATA: BEGIN OF data_tab OCCURS 0,
           value_0001(50),
           value_0002(50),
           value_0003(50),
           value_0004(50),
           value_0005(50),
           value_0006(50),
           value_0007(50),
           value_0008(50),
           value_0009(50),
           value_0010(50),
           value_0011(50),
           value_0012(50),
           value_0013(50),
           value_0014(50),
           value_0015(50),
           value_0016(50),
           value_0017(50),
           value_0018(50),
           value_0019(50),
           value_0020(50),
           value_0021(50),
           value_0022(50),
           value_0023(50),
           value_0024(50),
           value_0025(50),
           value_0026(50),
           value_0027(50),
           value_0028(50),
           value_0029(50),
           value_0030(50),
           value_0031(50),
           value_0032(50),
           value_0033(50),
           value_0034(50),
           value_0035(50),
           value_0036(50),
           value_0037(50),
           value_0038(50),
           value_0039(50),
           value_0040(50),
           value_0041(50),
           value_0042(50),
           value_0043(50),
           value_0044(50),
           value_0045(50),
           value_0046(50),
           value_0047(50),
           value_0048(50),
           value_0049(50),
           value_0050(50),
           value_0051(50),
           value_0052(50),
           value_0053(50),
           value_0054(50),
           value_0055(50),
           value_0056(50),
           value_0057(50),
           value_0058(50),
           value_0059(50),
           value_0060(50),
           value_0061(50),
           value_0062(50),
           value_0063(50),
           value_0064(50),
           value_0065(50),
           value_0066(50),
           value_0067(50),
           value_0068(50),
           value_0069(50),
           value_0070(50),
           value_0071(50),
           value_0072(50),
           value_0073(50),
           value_0074(50),
           value_0075(50),
           value_0076(50),
           value_0077(50),
           value_0078(50),
           value_0079(50),
           value_0080(50),
           value_0081(50),
           value_0082(50),
           value_0083(50),
           value_0084(50),
           value_0085(50),
           value_0086(50),
           value_0087(50),
           value_0088(50),
           value_0089(50),
           value_0090(50),
           value_0091(50),
           value_0092(50),
           value_0093(50),
           value_0094(50),
           value_0095(50),
           value_0096(50),
           value_0097(50),
           value_0098(50),
           value_0099(50),
           value_0100(50).
    DATA: END OF data_tab.
    DATA: tind(4) TYPE n.
    DATA: zwfeld(19).
    FIELD-SYMBOLS: <fs1>.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
           EXPORTING
                mask      = '*.xls'
                static    = 'X'
           CHANGING
                file_name = filename.
    START-OF-SELECTION.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = filename
                i_begin_col             = begcol
                i_begin_row             = begrow
                i_end_col               = endcol
                i_end_row               = endrow
           TABLES
                intern                  = intern
           EXCEPTIONS
                inconsistent_parameters = 1
                upload_ole              = 2
                OTHERS                  = 3.
      IF sy-subrc <> 0.
        WRITE:/ 'Upload Error ', SY-SUBRC.
      ENDIF.
    END-OF-SELECTION.
      LOOP AT intern.
        intern1 = intern.
        CLEAR intern1-row.
        APPEND intern1.
      ENDLOOP.
      SORT intern1 BY col.
      LOOP AT intern1.
        AT NEW col.
          t_col-col = intern1-col.
          APPEND t_col.
        ENDAT.
        zwlen = strlen( intern1-value ).
        READ TABLE t_col WITH KEY col = intern1-col.
        IF sy-subrc EQ 0.
          IF zwlen > t_col-size.
            t_col-size = zwlen.
    *                          Internal Table, Current Row Index
            MODIFY t_col INDEX sy-tabix.
          ENDIF.
        ENDIF.
      ENDLOOP.
      DESCRIBE TABLE t_col LINES zwlines.
      SORT intern BY row col.
      IF kzheader = 'X'.
        LOOP AT intern.
          fieldnames-title = intern-value.
          APPEND fieldnames.
          AT END OF row.
            EXIT.
          ENDAT.
        ENDLOOP.
      ELSE.
        DO zwlines TIMES.
          WRITE sy-index TO fieldnames-title.
          APPEND fieldnames.
        ENDDO.
      ENDIF.
      SORT intern BY row col.
      LOOP AT intern.
        IF kzheader = 'X'
        AND intern-row = 1.
          CONTINUE.
        ENDIF.
        tind = intern-col.
        CONCATENATE 'DATA_TAB-VALUE_' tind INTO zwfeld.
        ASSIGN (zwfeld) TO <fs1>.
        <fs1> = intern-value.
        AT END OF row.
          APPEND data_tab.
          CLEAR data_tab.
        ENDAT.
      ENDLOOP.
      CALL FUNCTION 'DISPLAY_BASIC_LIST'
           EXPORTING
                file_name     = filename
           TABLES
                data_tab      = data_tab
                fieldname_tab = fieldnames.
    *-- End of Program
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/excel-file-download-to-an-internal-table-in-sap-crm-1719453#
    tables: zinv_release,
    zpo_release.
    ** decleration of data
    DATA: BEGIN OF my_tab OCCURS 0.
    INCLUDE STRUCTURE zinv_release.
    DATA: END OF my_tab.
    *DATA: hex_tab TYPE x VALUE '09'.
    DATA: rec(200)."'/usr/test.dat'.
    DATA:
    zhours(20) TYPE c,
    MINS(20) type c. "decimals.
    data: coma.
    coma = ','.
    SELECTION-SCREEN BEGIN OF BLOCK txt
    WITH FRAME TITLE text-001.
    PARAMETERS: dsn(60) DEFAULT '\\sapdev01\prod\'.
    SELECTION-SCREEN END
    OF BLOCK txt.
    *using a dataset to get text
    OPEN DATASET dsn FOR INPUT IN TEXT MODE.
    IF sy-subrc = 0.
    DO.
    READ DATASET dsn INTO rec.
    IF sy-subrc <> 0.
    EXIT.
    ENDIF.
    split rec at coma into
    zpo_release-REL_GRP
    zpo_release-REL_CODE
    zpo_release-RESPREL
    zpo_release-ALTREL
    zpo_release-MANAGER
    ZHOURS
    MINS
    zpo_release-FROMTIME
    zpo_release-TOTIME
    zpo_release-EXCLWKENDS.
    move zpo_release-REL_GRP to my_tab-REL_GRP.
    move zpo_release-REL_CODE to my_tab-REL_CODE.
    move zpo_release-RESPREL to my_tab-RESPREL.
    move zpo_release-ALTREL to my_tab-ALTREL.
    move zpo_release-MANAGER to my_tab-MANAGER.
    move ZHOURS to my_tab-ZHOURS.
    move MINS to my_tab-mins.
    move zpo_release-FROMTIME to my_tab-fromtime.
    move zpo_release-TOTIME to my_tab-totime.
    move zpo_release-EXCLWKENDS to my_tab-exclwkends.
    APPEND my_tab.
    ENDDO.
    INSERT zpo_release FROM TABLE my_tab ACCEPTING DUPLICATE KEYS.
    ** DELETE zmm_ppa_cc FROM TABLE tab.
    ** INSERT zzzak_emp FROM TABLE my_tab ACCEPTING DUPLICATE KEYS.
    IF sy-subrc = 0.
    MESSAGE i000(zv) WITH 'File Successful stored in DB.' '' '' ''.
    ** ELSE.
    MESSAGE i000(zv) WITH 'File already stored in DB.' '' '' ''.
    endif.
    ENDIF.
    reward if helpful
    raam

  • Convert  XML page into Internal Table

    Hi,
    I'm not sure if this post belongs here or not, but here goes.
    I have a requirement to read in data from a xml page and save the contents into a ABAP internal table.
    At the moment, I have extracted the contents of the XML page into a string using the IF_HTTP_CLIENT->RESPONSE->GET_CDATA method.
    Now I underatand that SAP has XSLT documents that can be used to transform XML documents into ABAP Data Structures.
    Can someone explain to me how this works? I have looked in SAP Help about the XSLT Editor, but it still looks like double dutch to me (no offence to the dutch people out there!).
    Thanks,
    Pat.

    You can use either XSLT programming or Simple Transformation to do that job. check out the following weblogs.
    <a href="/people/tobias.trapp/blog/2005/05/04/xml-processing-in-abap-part-1">XML processing in ABAP Part 1</a>
    <a href="/people/tobias.trapp/blog/2005/05/17/xml-processing-in-abap-part-2">XML processing in ABAP Part 2</a>
    <a href="/people/tobias.trapp/blog/2005/05/20/xml-processing-in-abap-part-3">XML processing in ABAP Part 3</a>
    <a href="/people/tobias.trapp/blog/2005/05/27/xml-processing-in-abap-part-4">XML processing in ABAP Part 4</a>
    <a href="/people/tobias.trapp/blog/2005/06/15/xml-processing-in-abap--part-5">XML processing in ABAP Part 5</a>
    Regards
    Raja

  • Error converting CSV file into internal table

    Hi,
    I have to convert a large CSV file (>20.000 entries) into an internal table. I used FM GUI_UPLOAD to get a raw data table then convert this table using FM TEXT_CONVERT_CSV_TO_SAP.
    But this does not seem to work properly: after 16.000 or so, the FM seems stuck as if in an endless loop.
    Note that if I split the CSV file in several parts, the conversion runs successfully.
    Is there any memory limit with this FM ?
    Thanks,
    Florian

    Florian Labrouche,
    Instead of using two function modules, you can use  'TEXT_CONVERT_XLS_TO_SAP' function module once by specifying file name in that function module itself. It does not take much time.
    Check the sample program.
    report  zvenkat-upload-xl  no standard page heading.
    "Declarations.
    "types
    types:
          begin of t_bank_det,
            pernr(8)  type c,
            bnksa(4)  type c,
            zlsch(1)  type c,
            bkplz(10) type c,
            bkort(25) type c,
            bankn(18) type c,
          end of t_bank_det.
    "work areas
    data:
          w_bank_det type t_bank_det.
    "internal tables
    data:
          i_bank_det type table of t_bank_det.
    " selection-screen
    selection-screen begin of block b1 with frame title text_001.
    parameters p_file type localfile.
    selection-screen end of block b1.
    "At selection-screen on value-request for p_file.
    at selection-screen on value-request for p_file.
      perform f4_help.
      "Start-of-selection.
    start-of-selection.
      perform upload_data.
      "End-of-selection.
    end-of-selection.
      perform display_data.
      "Form  f4_help
    form f4_help .
      data:
            l_file_name like  ibipparms-path  .
      call function 'F4_FILENAME'
        exporting
          program_name  = syst-cprog
          dynpro_number = syst-dynnr
          field_name    = 'P_FILE'
        importing
          file_name     = l_file_name.
      p_file = l_file_name.
    endform.                                                    " f4_help
    "Form  upload_data
    form upload_data .
      type-pools:truxs.
      data:li_tab_raw_data type  truxs_t_text_data.
      data:l_filename      like  rlgrap-filename.
      l_filename = p_file.
      call function 'TEXT_CONVERT_XLS_TO_SAP'
        exporting
          i_tab_raw_data       = li_tab_raw_data
          i_filename           = l_filename
        tables
          i_tab_converted_data = i_bank_det
        exceptions
          conversion_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.                    " upload_data
    " Form  display_data
    form display_data .
      data: char100 type char100.
      loop at i_bank_det into w_bank_det .
        if sy-tabix = 1.
          write w_bank_det.
          write / '------------------------------------------------------------'.
        else.
          write / w_bank_det.
        endif.
      endloop.
    endform.                    " display_data
    Regards,
    Venkat.O

  • How to convert XML file into DTD or XSD

    Hi Folks,
    This is the output structure I need to get. My interface is file to file. Can u please let me know How do I create a data type or any XSD to get below Structure.
    <?xml version="1.0" encoding="UTF-8" ?>
    - <Command xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Command.xsd">
    - <WriteTagData readerID="EasyDP">
    - <Item>
    - <FieldList format="C:\Documents and Settings\wlee\Desktop\Format_4A.btw" jobName="Test1" quantity="1">
      <Field name="PlantNo">4012</Field>
      <Field name="PlantName">ANE</Field>
      <Field name="SKU">12000001</Field>
      <  </FieldList>
      </Item>
      </WriteTagData>
      </Command>
    Please help me How would I create Data type for this. Your help is highly apreciated
    Thanks,
    Enivass

    Hi Enivas,
    >>>>>>>>>Please help me how would I delete ns0.
    For  remove ns0,  you have to do use XMLAnonymizerBean module  in adpater module (In Communication channel).
    Insert the XMLAnonymizerBean before the CallSapAdapter .
    The module name u2018CallSapAdapteru2019 is default one that can be left as it is.
    Module Name : AF_Modules/XMLAnonymizerBean
    Type: Local Enterprise Bean
    Module Key: 0  
    Add Parameters in the Module Configuration
    2.       Module Key: 0
    Parameter Name: anonymizer.acceptNamespaces
    Parameter Value: <namespace> u2018u2019  
    Enter a list of namespaces and their prefixes that are to be kept in the target XML document and to result a namespace without a prefix, enter u2018 u2018 (two single quotation marks).   In your case like namespace http://www.w3.org/2001/XMLSchema-instance follow with two single quotation marks.
    3.       Module Key: 0
    Parameter Name: anonymizer.quote
    Parameter Value: u2018
    Here specify the character to be used to enclose the attribute values.  The default value is u2018.  
    When scenario is executed, the target message contains the namespace with no prefix.  
    Then, you are not facing any issue in target messages.
    Regards,
    Rajesh

  • How to convert XML file to an internal table ?

    Hi All,
    I want to do a batch input program. The source data would be given as an excel file . I would like to know how to convert XML file to internal table properly. Please help me out..
    Thanking you in advance ..
    Shankara Narayanan T.V

    Hi Shankar,
    use 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
             EXPORTING
                  filename                = p_file1
                  i_begin_col             = '1'
                  i_begin_row             = '5'
                  i_end_col               = '40'
                  i_end_row               = '16'
             TABLES
                  intern                  = it_intern
             EXCEPTIONS
                  inconsistent_parameters = 1
                  upload_ole              = 2
                  OTHERS                  = 3.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    LOOP AT it_intern.
          AT NEW row.
            CLEAR it_intern.
          ENDAT.
            CASE lv_flag.
        Production Version
              WHEN  1.
                it_master-matnr      =   it_intern-value.     
              WHEN  2.
                it_master-werks      = it_intern-value.
              WHEN  3.
                it_master-verid      = it_intern-value.
              WHEN  4.
                it_master-text1      = it_intern-value.
              WHEN  5.
                it_master-fdate     = it_intern-value.
          AT END OF row.
            APPEND it_master.
          ENDAT.
        ENDLOOP.
    -Anu
    Message was edited by:
            Anupama Reddy

  • How to get data of tabulated text file into internal table

    hi all,
    i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding  how to convert excel file into internal table but i didnt get posts regarding text file.
    thanks
    SAchin

    try:
    DATA: BEGIN OF tabulator,
            x(1) TYPE x VALUE '09',
          END OF tabulator.
      READ DATASET file INTO wa.
    split wa at tabulator into table itab.
    A.

  • Problem converting data in XML file to internal table data

    Hi all,
    I have a requirement. I need to convert an XML file to internal table data and based on that data do Goods Receipt in SAP.
    With the help of this blog /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
    I am able to convert the XML file to data in SAP. But this blog will display the output on screen as ELELEMNT = nodename VALUE= value of that node.
    But I donu2019t want in that way, I want to store all the data in XML file in an internal table so that I can make use of those values and do Goods Recipt in SAP.
    Can some one suggest how should I read the data in an internal table.
    Here is my code..what changes should I make?
    *& Report  z_xit_xml_check
      REPORT  z_xit_xml_check.
      TYPE-POOLS: ixml.
      TYPES: BEGIN OF t_xml_line,
              data(256) TYPE x,
            END OF t_xml_line.
      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 'c:\temp\orders_dtd.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( ).
        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.
        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.
          CASE node->get_type( ).
            WHEN if_ixml_node=>co_node_element.
            element node
              name    = node->get_name( ).
              nodemap = node->get_attributes( ).
              WRITE: / 'ELEMENT  :'.
              WRITE: AT indent name COLOR COL_POSITIVE INVERSE.
              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     :'.
              WRITE: AT indent value COLOR COL_GROUP INVERSE.
          ENDCASE.
        advance to next node
          node = iterator->get_next( ).
        ENDWHILE.
      ENDFORM.                    "process_dom
    Any help would be highly apperciated.
    regards,
    Jessica Sam

    Pavel Vera,
    With your example i tries doing the following .....
    I tried  to convert the data of XML file to internal table data. I am collecting the data in internal table to do goos recipt with that data.
    Please find my XML file, ABAP pgm and XSLT pgm . I donu2019t know what I am missing I am not getting any output. I donu2019t know what is wrong please help me with this
    Below is my XML file, My code and XSLT Program. In the below XML file I need to collect Vendor Number, Order Number, and Date tags which occur only once for one XML file.
    I also need to collect the following tags from <Shipmentdetail>
    <Shipmentdetail> has following child nodes and I need to collect them
    TrackingNumber
    Freight
    Weight
    ShipmentDate
    ShipmentMethod
    Need to collect to collect the following tags from <ProductInformation>
    <ProductInformation> has following child nodes and I need to collect them
        LineNumber
        SKUNumber
        OrderedQuantity
        ShippedQuantity
        UOM
    The <Shipmentdetail> and <ProductInformation> are child nodes of <OrderShipment>
    The <Shipmentdetail> occurs only ones but the <ProductInformation> can occur once or many times and will be dynamic and differs depening on the input file.
    My XML file is as follows
    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <ShipmentHeader>
      <AccountID />
    - <OrderShipment>
          <VendorNumber>1000</VendorNumber>
          <OrderNumber>P00009238</OrderNumber>
          <OrderType>Stock</OrderType>
          <Company />
          <Division />
         <Department />
         <Date>20061120</Date>
         <CartonCount>2</CartonCount>
         <ShipAllProducts>No</ShipAllProducts>
    -             <ShipmentDetail>
                      <TrackingNumber>1ZR3W891PG47477811</TrackingNumber>
                      <Freight>000000010000</Freight>
                      <ShipmentDate>20061120</ShipmentDate>
                      <ShipmentMethod>UPS1PS</ShipmentMethod>
                 </ShipmentDetail>
    -            <ProductInformation>
                     <LineNumber>000000001</LineNumber>
                     <SKUNumber>110FR</SKUNumber>
                     <AdvSKUNumber>003 4518</AdvSKUNumber>
                     <SKUID />
                     <OrderedQuantity>00000001000000</OrderedQuantity>
                     <ShippedQuantity>00000001000000</ShippedQuantity>
                     <UOM>EA</UOM>
                     <Factor>1</Factor>
                </ProductInformation>
    -           <ProductInformation>
                    <LineNumber>000000002</LineNumber>
                    <SKUNumber>938EN</SKUNumber>
                    <AdvSKUNumber>001 7294</AdvSKUNumber>
                    <SKUID />
                    <OrderedQuantity>00000000450000</OrderedQuantity>
                    <ShippedQuantity>00000000450000</ShippedQuantity>
                    <UOM>EA</UOM>
                    <Factor>1</Factor>
                </ProductInformation>
    -           <CaseInformation>
                   <LineNumber>000000001</LineNumber>
                   <SKUNumber>110FR</SKUNumber>
                   <AdvSKUNumber>003 4518</AdvSKUNumber>
                   <SKUID />
                   <SSCCNumber>00000001668000002487</SSCCNumber>
                   <CaseQuantity>00000001000000</CaseQuantity>
                   <UOM>EA</UOM>
                   <Factor>1</Factor>
                 </CaseInformation>
                 <CaseInformation>
                   <LineNumber>000000001</LineNumber>
                   <SKUNumber>110FR</SKUNumber>
                   <AdvSKUNumber>003 4518</AdvSKUNumber>
                   <SKUID />
                   <SSCCNumber>00000001668000002487</SSCCNumber>
                   <CaseQuantity>00000001000000</CaseQuantity>
                   <UOM>EA</UOM>
                   <Factor>1</Factor>
                 </CaseInformation>
    -  </OrderShipment>
      </ShipmentHeader>
    My Program
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\temp\test.xml'.
    * This is the structure for the data from the XML file
    TYPES: BEGIN OF ts_shipment,
             VendorNumber(10)     TYPE n,
             OrderNumber(20)      TYPE n,
             OrderType(8)         TYPE c,
             Date(8)              TYPE c,
           END OF ts_shipment.
    TYPES: BEGIN OF ts_shipmentdetail,
             TrackingNumber(30)     TYPE n,
             Freight(12)            TYPE n,
             Weight(14)             TYPE n,
             ShipmentDate(8)        TYPE c,
             ShipmentMethod(8)      TYPE c,
             END OF ts_shipmentdetail.
    TYPES: BEGIN OF ts_productinformation,
             LineNumber(9)          TYPE n,
             SKUNumber(20)          TYPE c,
             OrderedQuantity(14)    TYPE n,
             ShippedQuantity(14)    TYPE n,
             UOM(4)                 TYPE c,
             END OF ts_productinformation.
    * Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    * Table and work ares for the data from the XML file
    DATA: gt_shipment               TYPE STANDARD TABLE OF ts_shipment,
          gs_shipment               TYPE ts_shipment.
    DATA: gt_shipmentdetail         TYPE STANDARD TABLE OF ts_shipmentdetail,
          gs_shipmentdetail         TYPE ts_shipmentdetail.
    DATA: gt_productinformation     TYPE STANDARD TABLE OF ts_productinformation,
          gs_productinformation     TYPE ts_productinformation.
    * Result table that contains references
    * of the internal tables to be filled
    DATA: gt_result_xml TYPE abap_trans_resbind_tab,
          gs_result_xml TYPE abap_trans_resbind.
    * For error handling
    DATA: gs_rif_ex     TYPE REF TO cx_root,
          gs_var_text   TYPE string.
    * Get the XML file from your client
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = gs_file
      CHANGING
        data_tab                = gt_itab
      EXCEPTIONS
        file_open_error         = 1
        file_read_error         = 2
        no_batch                = 3
        gui_refuse_filetransfer = 4
        invalid_type            = 5
        no_authority            = 6
        unknown_error           = 7
        bad_data_format         = 8
        header_not_allowed      = 9
        separator_not_allowed   = 10
        header_too_long         = 11
        unknown_dp_error        = 12
        access_denied           = 13
        dp_out_of_memory        = 14
        disk_full               = 15
        dp_timeout              = 16
        not_supported_by_gui    = 17
        error_no_gui            = 18
        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.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "ISHIPMENT".
    GET REFERENCE OF gt_shipment INTO gs_result_xml-value.
    gs_result_xml-name = 'ISHIPMENT'.
    APPEND gs_result_xml TO gt_result_xml.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "ISHIPDET".
    GET REFERENCE OF gt_shipmentdetail INTO gs_result_xml-value.
    gs_result_xml-name = 'ISHIPDET'.
    APPEND gs_result_xml TO gt_result_xml.
    * Fill the result table with a reference to the data table.
    * Within the XSLT stylesheet, the data table can be accessed with
    * "IPRODDET".
    GET REFERENCE OF gt_productinformation  INTO gs_result_xml-value.
    gs_result_xml-name = 'IPRODDET'.
    APPEND gs_result_xml TO gt_result_xml.
    * Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION z_xml_to_abap3
        SOURCE XML gt_itab
        RESULT (gt_result_xml).
      CATCH cx_root INTO gs_rif_ex.
        gs_var_text = gs_rif_ex->get_text( ).
        MESSAGE gs_var_text TYPE 'E'.
    ENDTRY.
    * Writing the data from file for gt_shipment
    *Collecting the Shipping Data from the XML file to internal table gt_shipment
    *and writing the data to the screen
    LOOP AT gt_shipment INTO gs_shipment.
      WRITE: / 'VendorNumber:', gs_shipment-VendorNumber.
      WRITE: / 'OrderNumber :', gs_shipment-OrderNumber.
      WRITE: / 'OrderType  :', gs_shipment-OrderType.
      WRITE: / 'Date  :',      gs_shipment-Date.
      WRITE : /.
    ENDLOOP. "gt_shipment.
    LOOP AT gt_shipmentdetail INTO gs_shipmentdetail.
      WRITE: / 'TrackingNumber:',     gs_shipmentdetail-TrackingNumber.
      WRITE: / 'Freight :',           gs_shipmentdetail-Freight.
      WRITE: / 'Weight  :',           gs_shipmentdetail-Weight.
      WRITE: / 'ShipmentDate  :',     gs_shipmentdetail-ShipmentDate.
    * WRITE: / 'ShipmentMethod  :'    gs_shipmentdetail-ShipmentMethod
      WRITE : /.
    ENDLOOP. "gt_shipmentdetail.
    LOOP AT gt_productinformation INTO gs_productinformation.
      WRITE: / 'LineNumber:',         gs_productinformation-LineNumber.
      WRITE: / 'SKUNumber :',         gs_productinformation-SKUNumber.
      WRITE: / 'OrderedQuantity  :',  gs_productinformation-OrderedQuantity.
      WRITE: / 'ShippedQuantity  :',  gs_productinformation-ShippedQuantity.
      WRITE: / 'UOM  :',              gs_productinformation-UOM.
      WRITE : /.
    ENDLOOP. "gt_productinformation.
    XSLT Program
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.0"/>
      <xsl:strip-space elements="*"/>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <ISHIPMENT>
              <xsl:apply-templates select="//OrderShipment"/>
            </ISHIPMENT>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="OrderShipment">
        <item>
          <VENDORNUMBER>
            <xsl:value-of select="VendorNumber"/>
          </VENDORNUMBER>
          <ORDERNUMBER>
            <xsl:value-of select="OrderNumber"/>
          </ORDERNUMBER>
          <ORDERTYPE>
            <xsl:value-of select="OrderType"/>
          </ORDERTYPE>
          <DATE>
            <xsl:value-of select="Date"/>
          </DATE>
        </item>
      </xsl:template>
      <xsl:template match="/">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <ISHIPDET>
              <xsl:apply-templates select="//OrderShipment/ShipmentDetail"/>
            </ISHIPDET>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="ShipmentDetail">
        <item>
          <TRACKINGNUMBER>
            <xsl:value-of select="TrackingNumber"/>
          </TRACKINGNUMBER>
          <FREIGHT>
            <xsl:value-of select="Freight"/>
          </FREIGHT>
          <SHIPMENTDATE>
            <xsl:value-of select="ShipmentDate"/>
          </SHIPMENTDATE>
          <SHIPMENTMETHOD>
            <xsl:value-of select="ShipmentMethod"/>
          </SHIPMENTMETHOD>
        </item>
      </xsl:template>
    </xsl:transform> .
    Any help is highly appreciated. If anyone encountered this situation before please let me know where i am going wrong in my XSLT transformation.
    Any Help will be highly apppreciated. Thanks in advance
    Regards,
    Jessica   Sam

  • How to load a XML file into a table using PL/SQL

    Hi Guru,
    I have a requirement, that i have to create a procedure or a package in PL/SQL to load  XML file into a table.
    How we can achive this.

    ODI_NewUser wrote:
    Hi Guru,
    I have a requirement, that i have to create a procedure or a package in PL/SQL to load  XML file into a table.
    How we can achive this.
    Not a perfectly framed question. How do you want to load the XML file? Hoping you want to parse the xml file and load it into a table you can do this.
    This is the xml file
    karthick% cat emp_details.xml
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
      <EMPNO>7782</EMPNO>
      <ENAME>CLARK</ENAME>
      <JOB>MANAGER</JOB>
      <MGR>7839</MGR>
      <HIREDATE>09-JUN-1981</HIREDATE>
      <SAL>2450</SAL>
      <COM>0</COM>
      <DEPTNO>10</DEPTNO>
    </ROW>
    <ROW>
      <EMPNO>7839</EMPNO>
      <ENAME>KING</ENAME>
      <JOB>PRESIDENT</JOB>
      <HIREDATE>17-NOV-1981</HIREDATE>
      <SAL>5000</SAL>
      <COM>0</COM>
      <DEPTNO>10</DEPTNO>
    </ROW>
    </ROWSET>
    You can write a query like this.
    SQL> select *
      2    from xmltable
      3         (
      4            '/ROWSET/ROW'  passing xmltype
      5            (
      6                 bfilename('SDAARBORDIRLOG', 'emp_details.xml')
      7               , nls_charset_id('AL32UTF8')
      8            )
      9            columns empno    number      path 'EMPNO'
    10                  , ename    varchar2(6) path 'ENAME'
    11                  , job      varchar2(9) path 'JOB'
    12                  , mgr      number      path 'MGR'
    13                  , hiredate varchar2(20)path 'HIREDATE'
    14                  , sal      number      path 'SAL'
    15                  , com      number      path 'COM'
    16                  , deptno   number      path 'DEPTNO'
    17         );
         EMPNO ENAME  JOB              MGR HIREDATE                    SAL        COM     DEPTNO
          7782 CLARK  MANAGER         7839 09-JUN-1981                2450          0         10
          7839 KING   PRESIDENT            17-NOV-1981                5000          0         10
    SQL>

  • How to load a XML file into a table

    Hi,
    I've been working on Oracle for many years but for the first time I was asked to load a XML file into a table.
    As an example, I've found this on the web, but it doesn't work
    Can someone tell me why? I hoped this example could help me.
    the file acct.xml is this:
    <?xml version="1.0"?>
    <ACCOUNT_HEADER_ACK>
    <HEADER>
    <STATUS_CODE>100</STATUS_CODE>
    <STATUS_REMARKS>check</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>2</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>3</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic administration</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>4</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>5</SEGMENT_NUMBER>
    <REMARKS>rp polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    <HEADER>
    <STATUS_CODE>500</STATUS_CODE>
    <STATUS_REMARKS>process exception</STATUS_REMARKS>
    </HEADER>
    <DETAILS>
    <DETAIL>
    <SEGMENT_NUMBER>20</SEGMENT_NUMBER>
    <REMARKS> base polytechnic</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>30</SEGMENT_NUMBER>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>40</SEGMENT_NUMBER>
    <REMARKS> base polytechnic finance</REMARKS>
    </DETAIL>
    <DETAIL>
    <SEGMENT_NUMBER>50</SEGMENT_NUMBER>
    <REMARKS> base polytechnic logistics</REMARKS>
    </DETAIL>
    </DETAILS>
    </ACCOUNT_HEADER_ACK>
    For the two tags HEADER and DETAILS I have the table:
    create table xxrp_acct_details(
    status_code number,
    status_remarks varchar2(100),
    segment_number number,
    remarks varchar2(100)
    before I've created a
    create directory test_dir as 'c:\esterno'; -- where I have my acct.xml
    and after, can you give me a script for loading data by using XMLTABLE?
    I've tried this but it doesn't work:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    This should allow me to get something like this:
    select * from xxrp_acct_details;
    Statuscode status remarks segement remarks
    100 check 2 rp polytechnic
    100 check 3 rp polytechnic administration
    100 check 4 rp polytechnic finance
    100 check 5 rp polytechnic logistics
    500 process exception 20 base polytechnic
    500 process exception 30
    500 process exception 40 base polytechnic finance
    500 process exception 50 base polytechnic logistics
    but I get:
    Error report:
    ORA-06550: line 19, column 11:
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    ORA-06550: line 4, column 2:
    PL/SQL: SQL Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    and if I try to change the script without using the column HEADER_NO to keep track of the header rank inside the document:
    DECLARE
    acct_doc xmltype := xmltype( bfilename('TEST_DIR','acct.xml'), nls_charset_id('AL32UTF8') );
    BEGIN
    insert into xxrp_acct_details (status_code, status_remarks, segment_number, remarks)
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    END;
    I get this message:
    Error report:
    ORA-19114: error during parsing the XQuery expression: 
    ORA-06550: line 1, column 13:
    PLS-00201: identifier 'SYS.DBMS_XQUERYINT' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-06512: at line 4
    19114. 00000 -  "error during parsing the XQuery expression: %s"
    *Cause:    An error occurred during the parsing of the XQuery expression.
    *Action:   Check the detailed error message for the possible causes.
    My oracle version is 10gR2 Express Edition
    I do need a script for loading xml files into a table as soon as possible, Give me please a simple example for understanding and that works on 10gR2 Express Edition
    Thanks in advance!

    The reason your first SQL statement
    select x1.status_code,
            x1.status_remarks,
            x2.segment_number,
            x2.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS[$hn]/DETAIL'
      passing acct_doc as "d",
              x1.header_no as "hn"
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS'
    ) x2
    returns the error you noticed
    PL/SQL: ORA-00932: inconsistent datatypes: expected - got NUMBER
    is because Oracle is expecting XML to be passed in.  At the moment I forget if it requires a certain format or not, but it is simply expecting the value to be wrapped in simple XML.
    Your query actually runs as is on 11.1 as Oracle changed how that functionality worked when 11.1 was released.  Your query runs slowly, but it does run.
    As you are dealing with groups, is there any way the input XML can be modified to be like
    <ACCOUNT_HEADER_ACK>
    <ACCOUNT_GROUP>
    <HEADER>....</HEADER>
    <DETAILS>....</DETAILS>
    </ACCOUNT_GROUP>
      <ACCOUNT_GROUP>
      <HEADER>....</HEADER>
      <DETAILS>....</DETAILS>
      </ACCOUNT_GROUP>
    </ACCOUNT_HEADER_ACK>
    so that it is easier to associate a HEADER/DETAILS combination?  If so, it would make parsing the XML much easier.
    Assuming the answer is no, here is one hack to accomplish your goal
    select x1.status_code,
            x1.status_remarks,
            x3.segment_number,
            x3.remarks
    from xmltable(
      '/ACCOUNT_HEADER_ACK/HEADER'
      passing acct_doc
      columns header_no      for ordinality,
              status_code    number        path 'STATUS_CODE',
              status_remarks varchar2(100) path 'STATUS_REMARKS'
    ) x1,
    xmltable(
      '$d/ACCOUNT_HEADER_ACK/DETAILS'
      passing acct_doc as "d",
      columns detail_no      for ordinality,
              detail_xml     xmltype       path 'DETAIL'
    ) x2,
    xmltable(
      'DETAIL'
      passing x2.detail_xml
      columns segment_number number        path 'SEGMENT_NUMBER',
              remarks        varchar2(100) path 'REMARKS') x3
    WHERE x1.header_no = x2.detail_no;
    This follows the approach you started with.  Table x1 creates a row for each HEADER node and table x2 creates a row for each DETAILS node.  It assumes there is always a one and only one association between the two.  I use table x3, which is joined to x2, to parse the many DETAIL nodes.  The WHERE clause then joins each header row to the corresponding details row and produces the eight rows you are seeking.
    There is another approach that I know of, and that would be using XQuery within the XMLTable.  It should require using only one XMLTable but I would have to spend some time coming up with that solution and I can't recall whether restrictions exist in 10gR2 Express Edition compared to what can run in 10.2 Enterprise Edition for XQuery.

  • How to convert HL7 file into an XML

    Hi All,
    I am new to HL7,can any one tell how to convert HL7 file into an XML.Give sample demo or related links.
    My sample HL7 file is as follows how can I convert.
    FHS|^~\&||Tax ID123^Lab Name123^L|||201110191435||HL7.txt||1234567|123||
    PID|seqno|123||john^chambers^^Dr^Dr|2456 california ave^San jose^CA^85254|19601212|M
    FHS|^~\&||Tax ID123^Lab Name123^L|||File Creaqted Date|File Security|FileName||File HeaderComment||Facility|FileCreatedDateTime|File Security|File Name|File Header Comment|FileControlId|Reference File Control ID|
    PID|seqno|patientId||LastName^FirstName^MiddleName^Title^Degree|Street^City^State^zip|patientDOB|gender
    <Report>
    <FileHeader>
    <FileSendingApplication> </FileSendingApplication>
    <TaxID>Tax ID123</TaxID>
    <LabName>Lab Name123</LabName>
    <FileSendngFacilityType>L</FileSendngFacilityType>
    <FileReceivingApplication></FileReceivingApplication>
    <FileReceivingFacility></FileReceivingFacility>
    <FileCreatedDateTime>201110191435</FileCreatedDateTime>
    <FileSecurity></FileSecurity>
    <FileName>HL7.txt</FileName>
    <FileHeaderComment></FileHeaderComment>
    <FileControlId>1234567</FileControlId>
    <ReferenceFileControlID></ReferenceFileControlID>
    <FileHeader>
    <Patient>
    <seqno> </seqno>
    <patientId>Tax ID123</patientId>
    <LastName>Lab Name123</LastName>
    <FirstName>L</FirstName>
    <MiddleName></MiddleName>
    <Title> </Title>
    <Degree></Degree>
    <Street></Street>
    <City></City>
    <State>HL7.txt</State>
    <Zip></Zip>
    <patientDOB>1234567</patientDOB>
    <gender></gender>
    <Patient>
    </Report>
    Thanks
    Mani

    Hi Prabu,
    With input as in single line I'm able to get the the output but with the multiple lines of input,error was occured.Any suggestions.
    Error while translating. Translation exception. Error occured while translating content from file C:\temp\sampleHL7.txt Please make sure that the file content conforms to the schema. Make necessary changes to the file content or the schema.
    The payload details for this rejected message can be retrieved.          Show payload...
    Thanks
    Mani

  • How do I upload XML files into sap table?

    Dear all,
    I found some methods that upload xml into SAP,
    but there doesn’t work under 4.6c.
    Can someone tell me how to upload XML files into
    sap under 4.6c?
    THX!

    hi,
    You can convert XML to abap using transformations. Simple transformations is a proprietary SAP programming language that describes the transformation of ABAP data to XML (serialization) and from XML to ABAP data (deserialization).
    goto SE80->workbench->edit object(or other objects)->in object selection chose more tab and then choose the transformation radio button and write a name and click create new.
    Here you enter your transformation like
    <xsl:transform version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:sap="http://www.sap.com/sapxsl"
    >
    <xsl:strip-space elements="*"/>
    <xsl:template match="/">
      <xsl:copy-of select="."/>
    </xsl:template>
    </xsl:transform>
    You can use this transfomation in your program using call transformation. You can find more info on call transformation in help.
    Hope this helps.
    Regards,
    Richa

  • Convert XML values to internal table

    Hi Experts
    How can i convert XML values to internal table . i am getting all the values into the string.
    this is my example
    <?xml version="1.0" encoding="UTF-8"?><TEST><ZTEST><DEPTNO>HEADOFFICE</DEPTNO><DNAME>IT</DNAME><LOC>HYD</LOC><MANDT>003</MANDT></ZTEST></TEST>
    i did create internal table with 4 fields.
    Please help.

    XML DOM Processing in ABAP part I -  Convert an ABAP table into XML file using SAP DOM Approach.

  • Getting Issue while uploading CSV file into internal table

    Hi,
    CSV file Data format as below
         a             b               c              d           e               f
    2.01E14     29-Sep-08     13:44:19     2.01E14     SELL     T+1
    actual values of column   A is 201000000000000
                     and  columen D is 201000000035690
    I am uploading above said CSV file into internal table using
    the below coding:
    TYPES: BEGIN OF TY_INTERN.
            INCLUDE STRUCTURE  KCDE_CELLS.
    TYPES: END OF TY_INTERN.
    CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
        EXPORTING
          I_FILENAME      = P_FILE
          I_SEPARATOR     = ','
        TABLES
          E_INTERN        = T_INTERN
        EXCEPTIONS
          UPLOAD_CSV      = 1
          UPLOAD_FILETYPE = 2
          OTHERS          = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    am getting all columns data into internal table,
    getting problem is columan A & D. am getting values into internal table for both; 2.01E+14. How to get actual values without modifying the csv file format.
    waiting for your reply...
    thanks & regards,
    abhi

    Hi Saurabh,
    Thanks for your reply.
    even i can't double click on those columns.
    b'se the program needs be executed in background there can lot of csv file in one folder. No manual interaction on those csv files.
    regards,
    abhi

  • Question about reading csv file into internal table

    Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
    I would like to ask how can I read a CSV file into internal table from files in application server?
    I can't simply use SPLIT as there may be comma in the content. e.g.
    "abc","aaa,ab",10,"bbc"
    My expected output:
    abc
    aaa,ab
    10
    bbb
    Thanks again for your help.

    Hi Gundam,
    Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
    OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
    DO.
    READ DATASET dsn INTO record.
      PERFORM parser USING record.
    ENDDO.
    *DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
    *DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
    *DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
    FORM parser USING str.
    DATA field(12).
    DATA field1(12).
    DATA field2(12).
    DATA field3(12).
    DATA field4(12).
    DATA cnt TYPE i.
    DATA len TYPE i.
    DATA temp TYPE i.
    DATA start TYPE i.
    DATA quote TYPE i.
    DATA rec_cnt TYPE i.
    len = strlen( str ).
    cnt = 0.
    temp = 0.
    rec_cnt = 0.
    DO.
    *  Start at the beginning
      IF start EQ 0.
        "string just ENDED start new one.
        start = 1.
        quote = 0.
        CLEAR field.
      ENDIF.
      IF str+cnt(1) EQ '"'.  "Check for qoutes
        "CHECK IF quotes is already set
        IF quote = 1.
          "Already quotes set
          "Start new field
          start = 0.
          quote = 0.
          CONCATENATE field '"' INTO field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            CONDENSE field.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
    *      WRITE field.
        ELSE.
          "This is the start of quotes
          quote = 1.
        ENDIF.
      ENDIF.
      IF str+cnt(1) EQ ','. "Check end of field
        IF quote EQ 0. "This is not inside quote end of field
          start = 0.
          quote = 0.
          CONDENSE field.
    *      WRITE field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CONCATENATE field str+cnt(1) INTO field.
      cnt = cnt + 1.
      IF cnt GE len.
        EXIT.
      ENDIF.
    ENDDO.
    WRITE: field1, field2, field3, field4.
    ENDFORM.
    Regards,
    Wenceslaus.

Maybe you are looking for