TEXT_CONVERT_XML_TO_SAP

Hi,
How to set the parameters in the function module.
TEXT_CONVERT_XML_TO_SAP
any example you have?
Regards,
Ratna

not a direct answer to your question.
brief us what you want to do , may be we could come up another FM of a better approach.
if you are looking at parsing XML check out this FM
SMUM_XML_PARSE
Regards
Raja

Similar Messages

  • Quection about function  TEXT_CONVERT_XML_TO_SAP

    hai to all,
    Please provide information regarding this function module
    if possible provide one example program on this function module
    TEXT_CONVERT_XML_TO_SAP
    regards,
    surya.

    In the import parameters pass the following data...
    1) Field Separator value
    2) Internal Table Line Header
    3) Raw data (Internal table data)
    4) File Name
    5) Total file size (Internal table count)
    This will inturn return data in the tables section which can be used.
    refer the below link
    TEXT_CONVERT_XML_TO_SAP

  • Testing function TEXT_CONVERT_XML_TO_SAP

    Hi,
    Function "TEXT_CONVERT_XML_TO_SAP" has status not released for customer therefore I cannot use it. I have copied the whole function group TRUX bat I still get the error en I try to test "Z_TEXT_CONVERT_XML_TO_SAP" . I have done the SQL trace but I do not find where to change the status in order to be able to do a test and I really need to use this function to read XML files into SAP.
    Please, any hint?
    Thnaks.
    Abel.

    Still fm is showing "Not released"
    You can test with calling this fm in a small abap test program and check , please don't test thru test enviornment SE37

  • How can I convert IF_IXML_DOCUMENT to STRING?

    Hi guys,
    is it possible to  convert an XML document (type IF_IXML_DOCUMENT ) to string.
    And how to do it?
    Thanks in advace!
    Regards,
    Liying

    Hi Wang,
    You can use these function modules
    TEXT_CONVERT_XML_TO_SAP or
    SDIXML_DOM_TO_XML Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
    or
    SMUM_XML_PARSE (Parse XML docment into a table structure)
    You can also refer to these:
    SMUM_XML_CREATE (Create XML document from internal table)
    SMUM_XML_CREATE_X (Create XSTRING xml doc)
    Check this code, it converts an XML data into a string internal table.
    REPORT Z_XML_TO_TABLE.
    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
    Thanks,
    Susmitha

  • Upload XML file from server to itab

    After failed to get a answer about download data from xml file in server to my itab, and searching and searching in hundred of post and threads i try my own solution for this issue.
    I read the file with:
    OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    In this case the result is a table filled with register type string like this:
    #<label>22222</label>
    I need a table with this kind of value (example):
    label   | 22222
    label2 | John
    label3 | Smith
    Therefore i have to parse the data of my table, i try with the FM:
    TEXT_CONVERT_XML_TO_SAP
    But dont works for me,
    I am too new in ABAP.
    The code for my report is very simple:
    REPORT ZPRUEBA_XML.
    DATA: BEGIN OF TABLA OCCURS 1,
    TEXTO(256) TYPE C,
    END OF TABLA.
    DATA: FICHERO LIKE RLGRAP-FILENAME.
    OPEN DATASET FICHERO FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF SY-SUBRC NE 0.
      WRITE:/ 'ERROR'.
    ENDIF.
    FREE TABLA.
    DO.
      READ DATASET FICHERO INTO TABLA.
      IF SY-SUBRC NE 0.
        EXIT.
      ELSE.
        APPEND TABLA.
        WRITE: TABLA-TEXTO.
      ENDIF.
    ENDDO.
    CLOSE DATASET FICHERO.
    And my ".xml" in the server is very simple too.
    <label>222222</label>
    <name>John</name>
    <street>Smith, 23, NY</street>
    Anyone can help me?
    Thanks

    Hi,
    You could use a transformation to do that, or call FM 'TEXT_CONVERT_XML_TO_SAP'... you also have the class IF_IXML that should help you and a lot of threads on the subject, such as:
    convert XML data into ABAP internal table
    ABAP Class to convert XML to itab
    Upload XML to internal table and vice versa in SAP 4.6C
    http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e66701fc-0d01-0010-9c9a-f8a36c4e87ba
    Kr,
    Manu.

  • Convert XML file to sap

    Dear friends
                  For converting XML file to SAP, I used TEXT_CONVERT_XML_TO_SAP function module. In this I have some doubt. Pls clarify this.
    1. I am getting run time error with type h.
    2  I_FIELD_SEPERATOR          = ';'
       I_LINE_HEADER              =
       I_TAB_RAW_DATA             =
       I_FILENAME                 =
       I_TOTALSIZE                =
    for the above parameter what are the value has to passed.
    Thanks.

    Hi,
    Take a look in this code:
    *& Report  z_xit_xml_check
      REPORT  z_xit_xml_check.
      TYPE-POOLS: ixml.
      DATA: BEGIN OF t_cabec OCCURS 0.
              INCLUDE STRUCTURE zmmt2010.
      DATA END OF t_cabec.
      DATA: BEGIN OF t_item OCCURS 0.
              INCLUDE STRUCTURE zmmt2011.
      DATA END OF t_item.
      DATA: BEGIN OF t_itemt OCCURS 0.
              INCLUDE STRUCTURE zmmt2012.
      DATA END OF t_itemt.
      TYPES: BEGIN OF t_xml_line,
              data(256) TYPE x,
            END OF t_xml_line.
      DATA check_item(1).
      DATA check_itemt(1).
      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:\xml.xml'.
      START-OF-SELECTION.
        PERFORM busca_xml.
        PERFORM carrega_tabela.
    *&      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.
      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 v_codcat TYPE zmmt2011-codcat.
        DATA v_master_for TYPE zmmt2011-master_for.
        node ?= document.
        CHECK NOT node IS INITIAL.
        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( ).
              TRANSLATE name TO LOWER CASE.
              IF name = 'iten'.
                MOVE 'I' TO check_item.
              ENDIF.
              IF name = 'cabec'.
                MOVE 'C' TO check_item.
              ENDIF.
              IF name = 'iten_texto'.
                MOVE 'T' TO check_item.
              ENDIF.
              nodemap = node->get_attributes( ).
              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( ).
                ENDDO.
              ENDIF.
            WHEN if_ixml_node=>co_node_text OR
                 if_ixml_node=>co_node_cdata_section.
            text node
              value  = node->get_value( ).
              IF check_item = 'C'.
                TRANSLATE name TO LOWER CASE.
                CASE name.
                  WHEN 'lifnr'.     MOVE value TO t_cabec-lifnr.
                  WHEN 'codcat'.
                    MOVE value TO t_cabec-codcat.
                    MOVE value TO v_codcat.
                  WHEN 'bukrs'.     MOVE value TO t_cabec-bukrs.
                  WHEN 'zterm'.     MOVE value TO t_cabec-zterm.
                  WHEN 'waers'.     MOVE value TO t_cabec-waers.
                  WHEN 'inco1'.     MOVE value TO t_cabec-inco1.
                  WHEN 'inco2'.     MOVE value TO t_cabec-inco2.
                  WHEN 'telf1'.     MOVE value TO t_cabec-telf1.
                  WHEN 'verkf'.     MOVE value TO t_cabec-verkf.
                  WHEN 'datav'.
                    MOVE value TO t_cabec-datav.
                    APPEND t_cabec.
                ENDCASE.
              ENDIF.
              IF check_item = 'I'.
                TRANSLATE name TO LOWER CASE.
                CASE name.
                  WHEN 'master_for'.
                    MOVE value TO t_item-master_for.
                    MOVE value TO v_master_for.
                  WHEN 'werks'.      MOVE value TO t_item-werks.
                  WHEN 'versao'.     MOVE value TO t_item-versao.
                  WHEN 'matkl'.      MOVE value TO t_item-matkl.
                  WHEN 'j_1bindus3'. MOVE value TO t_item-j_1bindus3.
                  WHEN 'j_1bmatuse'. MOVE value TO t_item-j_1bmatuse.
                  WHEN 'j_1bmatorg'. MOVE value TO t_item-j_1bmatorg.
                  WHEN 'j_1bnbmco1'. MOVE value TO t_item-j_1bnbmco1.
                  WHEN 'bsgru'.      MOVE value TO t_item-bsgru.
                  WHEN 'ekgrp'.      MOVE value TO t_item-ekgrp.
                  WHEN 'txz01'.      MOVE value TO t_item-txz01.
                  WHEN 'epstp'.      MOVE value TO t_item-epstp.
                  WHEN 'netpr'.      MOVE value TO t_item-netpr.
                  WHEN 'peinh'.      MOVE value TO t_item-peinh.
                  WHEN 'meins'.      MOVE value TO t_item-meins.
                  WHEN 'plifz'.      MOVE value TO t_item-plifz.
                  WHEN 'mwskz'.      MOVE value TO t_item-mwskz.
                  WHEN 'steuc'.
                    MOVE value TO t_item-steuc.
                    MOVE v_codcat TO t_item-codcat.
                    APPEND t_item.
                ENDCASE.
              ENDIF.
              IF check_item = 'T'.
                TRANSLATE name TO LOWER CASE.
                CASE name.
                  WHEN 'linha'.     MOVE value TO t_itemt-linha.
                  WHEN 'txlng'.     MOVE value TO t_itemt-txlng.
                    MOVE v_master_for TO t_itemt-master_for.
                    MOVE v_codcat     TO t_itemt-codcat.
                    append t_itemt.
                ENDCASE.
              ENDIF.
          ENDCASE.
        advance to next node
          node = iterator->get_next( ).
        ENDWHILE.
      ENDFORM.                    "process_dom
    *&      Form  Busca_XML
          text
    -->  p1        text
    <--  p2        text
      FORM busca_xml .
        DATA: lc_mess(70) TYPE c,lv_tab.
        TYPES: BEGIN OF ty_zvmsgorgtr.
                INCLUDE STRUCTURE zmmt2011.
        TYPES   END OF ty_zvmsgorgtr.
      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 ).
      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.
      ENDFORM.                    " Busca_XML
    *&      Form  Carrega_Tabela
          text
    -->  p1        text
    <--  p2        text
      FORM carrega_tabela .
      Process the document
        IF l_parser->is_dom_generating( ) EQ 'X'.
          PERFORM process_dom USING l_document.
        ENDIF.
      ENDFORM.                    " Carrega_Tabela

  • Problem in coverting XML data to Interal Table.

    Hello,
    I have to write an application which converts an Internal Table Data to XML String and then from XML String to an Internal Table.
    The reason for doing is that I am using an RFC Function module and the internal table is dynamically generated one.
    But somehow the XML data is not getting converted to Internal Table.
    The RFC returns Internal Table Data as XML and the Field Catalogue table
    Now in the application which calls RFC, I am trying to convert XML data to a dynamic Internal table
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
      CALL FUNCTION 'SCMS_BINARY_TO_STRING'
    Now convert XML String to Internal table
    Using FMs 'SCMS_STRING_TO_XSTRING'
    "Now XString to Binary
      CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    CALL FUNCTION 'TEXT_CONVERT_XML_TO_SAP'
        EXPORTING
          i_tab_raw_data             = lt_xml_data
          i_totalsize                = lv_file_size
        TABLES
          i_tab_converted_data       = <fst_dyn_table>
       EXCEPTIONS
         conversion_failed          = 1
         OTHERS                     = 2
    In the FM 'TEXT_CONVERT_XML_TO_SAP' I am getting error Conversion failed.
    Now I tried with transformations.
    Here also my table is a dynamically created Internal table.
    TRY.
          CALL TRANSFORMATION ('ID')
           SOURCE root = lt_zmt_tdm_fmap
              RESULT XML lv_output_str.
        CATCH cx_root INTO gs_rif_ex.
          gs_var_text = gs_rif_ex->get_text( ).
          MESSAGE gs_var_text TYPE 'I'.
      ENDTRY.
    Now the lv_output_str gets populated with data
    But when I call Transformation again to convert XML to internal table, it does not throw error, but does not return any data also.
    TRY.
          CALL TRANSFORMATION ('ID')
          SOURCE XML = lv_output_str
          RESULT ref = <fst_dyn_table> .
        CATCH cx_root INTO gs_rif_ex.
          gs_var_text = gs_rif_ex->get_text( ).
          MESSAGE gs_var_text TYPE 'I'.
      ENDTRY.
    How can this be resolved.
    As pointed I am using RFC Function module, the parameters will be
    1) XML String with Internal table data
    2) Field Catalogue for Internal Table to be created dynamically.
    Regards,
    Vikas

    >
    Vikas Sridharan wrote:

    >       CALL TRANSFORMATION ('ID')
    >       SOURCE XML = lv_output_str "<============ ERRONEOUS = HERE
    >       RESULT ref = <fst_dyn_table> .
    >
    Remove the "=" sign, this code will work :
          CALL TRANSFORMATION ('ID')
          SOURCE XML lv_output_str
          RESULT ref = <fst_dyn_table> .

  • Loading xml file in SAP

    Hi,
    I have a requirement to load xml file into SAP. Can you please tell me most efficient way to do this? Is there any function available in SAP to load xml file?
    Please let me know. I would really appreciate this.
    Regards,
    Sanjeev

    HI,
    This is the link which will give you the Code
    http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XML_TO_ABAP_46C.html
    Use this XML file to Upload the same, this Program will work for your XML file also,
    http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/input_xml.xml
    See the below thread also
    Upload XML to internal table and vice versa in SAP 4.6C
    look at the below function moduel .. <b>TEXT_CONVERT_XML_TO_SAP</b>
    Regards
    Sudheer

  • Help regarding uploading an xml file

    Hi All
    I have to upload data from an xml file.
    I guess the function module SMUM_XML_PARSE can be used for achieving this. But can anybody please tell me the exact procedure to use this function module.
    The program is going for a dump showing a CALL_FUNCTION_CONFLICT_TYPE error.
    The code is as follows
    data: stab like smum_xmltb occurs 0 with header line.
    data: ret1 like bapiret2 occurs 0.
          call function 'SMUM_XML_PARSE'
            exporting
              xml_input       = 'C:TEST.XML'
            tables
              xml_table       = stab
              return          = ret1
    loop at stab.
      write:/ stab-hier,stab-type.
    endloop.
    Thanks in advance
    Sree Ramya

    hii
    as for fm
    CALL FUNCTION 'SMUM_XML_PARSE'
    EXPORTING
    XML_INPUT = inputstring
    TABLES
    XML_TABLE = xmltab
    RETURN = ZBAPIRET2.
    This function module converts yr xml file i.e. in inputstring into zmltab table. Then U can loop on table to check the content.
    go thru this link
    http://www.geocities.com/victorav15/sapr3/abapfun.html#xml
    and also refer the example
    check this code
    1. Convert internal table to XML.
    Here is a sample program to convert internal table to XML
    *& Report ZTESTXML *
    Report ZPRUEBA_MML_13 *
    Export an internal table to XML document *
    NO BORRAR ESTE CODIGO *
    report zprueba_mml_13.
    PANTALLA SELECCION *
    parameters: gk_ruta type rlgrap-filename.
    PANTALLA SELECCION *
    TYPE TURNOS *
    types: begin of turnos,
    lu like t552a-tpr01,
    ma like t552a-tpr01,
    mi like t552a-tpr01,
    ju like t552a-tpr01,
    vi like t552a-tpr01,
    sa like t552a-tpr01,
    do like t552a-tpr01,
    end of turnos.
    TYPE TURNOS *
    TYPE SOCIO *
    types: begin of socio,
    numero like pernr-pernr,
    reposicion like pa0050-zauve,
    nombre like pa0002-vorna,
    turnos type turnos,
    end of socio.
    TYPE SOCIO *
    ESTRUCTURA ACCESOS *
    data: begin of accesos occurs 0,
    socio type socio,
    end of accesos.
    ESTRUCTURA ACCESOS *
    START OF SELECTION *
    start-of-selection.
    perform llena_accesos.
    perform descarga_xml.
    end-of-selection.
    END OF SELECTION *
    FORM LLENA_ACCESOS *
    form llena_accesos.
    refresh accesos.
    clear accesos.
    move: '45050' to accesos-socio-numero,
    'MOISES MORENO' to accesos-socio-nombre,
    '0' to accesos-socio-reposicion,
    'T1' to accesos-socio-turnos-lu,
    'T2' to accesos-socio-turnos-ma,
    'T3' to accesos-socio-turnos-mi,
    'T4' to accesos-socio-turnos-ju,
    'T5' to accesos-socio-turnos-vi,
    'T6' to accesos-socio-turnos-sa,
    'T7' to accesos-socio-turnos-do.
    append accesos.
    clear accesos.
    move: '45051' to accesos-socio-numero,
    'RUTH PEÑA' to accesos-socio-nombre,
    '0' to accesos-socio-reposicion,
    'T1' to accesos-socio-turnos-lu,
    'T2' to accesos-socio-turnos-ma,
    'T3' to accesos-socio-turnos-mi,
    'T4' to accesos-socio-turnos-ju,
    'T5' to accesos-socio-turnos-vi,
    'T6' to accesos-socio-turnos-sa,
    'T7' to accesos-socio-turnos-do.
    append accesos.
    endform. "LLENA_ACCESOS
    FORM LLENA_ACCESOS *
    FORM DESCARGA_XML *
    form descarga_xml.
    data: l_dom type ref to if_ixml_element,
    m_document type ref to if_ixml_document,
    g_ixml type ref to if_ixml,
    w_string type xstring,
    w_size type i,
    w_result type i,
    w_line type string,
    it_xml type dcxmllines,
    s_xml like line of it_xml,
    w_rc like sy-subrc.
    data: xml type dcxmllines.
    data: rc type sy-subrc,
    begin of xml_tab occurs 0,
    d like line of xml,
    end of xml_tab.
    class cl_ixml definition load.
    g_ixml = cl_ixml=>create( ).
    check not g_ixml is initial.
    m_document = g_ixml->create_document( ).
    check not m_document is initial.
    write: / 'Converting DATA TO DOM 1:'.
    call function 'SDIXML_DATA_TO_DOM'
    exporting
    name = 'ACCESOS'
    dataobject = accesos[]
    importing
    data_as_dom = l_dom
    changing
    document = m_document
    exceptions
    illegal_name = 1
    others = 2.
    if sy-subrc = 0.
    write 'Ok'.
    else.
    write: 'Err =',
    sy-subrc.
    endif.
    check not l_dom is initial.
    w_rc = m_document->append_child( new_child = l_dom ).
    if w_rc is initial.
    write 'Ok'.
    else.
    write: 'Err =',
    w_rc.
    endif.
    call function 'SDIXML_DOM_TO_XML'
    exporting
    document = m_document
    importing
    xml_as_string = w_string
    size = w_size
    tables
    xml_as_table = it_xml
    exceptions
    no_document = 1
    others = 2.
    if sy-subrc = 0.
    write 'Ok'.
    else.
    write: 'Err =',
    sy-subrc.
    endif.
    loop at it_xml into xml_tab-d.
    append xml_tab.
    endloop.
    call function 'WS_DOWNLOAD'
    exporting
    bin_filesize = w_size
    filename = gk_ruta
    filetype = 'BIN'
    tables
    data_tab = xml_tab
    exceptions
    others = 10.
    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. "DESCARGA_XML
    FORM DESCARGA_XML *
    2. To convert XML to internal table.
    You can use these function modules
    TEXT_CONVERT_XML_TO_SAP or
    SDIXML_DOM_TO_XML Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
    or
    SMUM_XML_PARSE (Parse XML docment into a table structure)
    You can also refer to these:
    SMUM_XML_CREATE (Create XML document from internal table)
    SMUM_XML_CREATE_X (Create XSTRING xml doc)
    Check this code, it converts an XML data into a string internal table.
    REPORT Z_XML_TO_TABLE.
    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:     emporders_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
    Regards
    Naresh

  • XML message in report format

    Hi all,
    Is there a way i can present the XML messages in a report format?
    I have the table SXMSPMAST to get the message ID and using class CL_XMS_PERSIST we can get the entire message.
    But, i need to collate the different messages in different nodes from the XML message into a report format.
    Please advice.
    Thanks & Regards,
    Akshay

    Hi.
    u can use the function module 'TEXT_CONVERT_XML_TO_SAP' to get the XML data present in a file to an Internal Table in ABAP.
    also read this
    Upload XML to internal table and vice versa in SAP 4.6C
    Salil ....

  • Convert xml into SAP using dataset

    Hi All,
    How to convert XML into itab using dataset, in this conversion have any function module available? please give me a sample program (having any). and material also.
    Thanks,
    Suresh maniarasu

    Hi,
    First you need to get the XML file Data into SAP using the  Function Module and can populate the data into an inernal table.
    TEXT_CONVERT_XML_TO_SAP
    DMC_CONVERT_XML_TO_TABLE
    or you can use the following classes
    CL_RSRD_CONVERTER_XML
    CL_WDR_XML_CONVERT_UTIL
    CL_EXM_IM_ISHCM_CONV_XML_SAP
    Thank U,
    Jay....

  • Function Module to read xml

    Hi  All,
    How SAP reads a xml file ?
    Any function module , or code that can read xml file .
    Please let me know .
    Thanks

    HI abijit,
    See the below code.
    PARAMETERS: p_filnam TYPE localfile OBLIGATORY
    *DEFAULT 'C:\Documents and Settings\test.xml'.
    DEFAULT 'D:\xx.xml'.
    parameters : r1 radiobutton group r1,
                  r2 radiobutton group r1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filnam.
    DATA: l_v_fieldname TYPE dynfnam.
    l_v_fieldname = p_filnam.
    START-OF-SELECTION.
    TYPES : BEGIN OF ys_xml_line,
                 data(256) TYPE x,
             END OF ys_xml_line.
    TYPES: yt_xml_table TYPE TABLE OF ys_xml_line.
    DATA: tab_raw_data TYPE yt_xml_table.
    TYPES: t_xml_line(1024) TYPE x.
    DATA: l_xml_table       TYPE TABLE OF t_xml_line.
    CALL FUNCTION 'TEXT_CONVERT_XML_TO_SAP'
       EXPORTING
    *   I_FIELD_SEPERATOR          = ';'
    *   I_LINE_HEADER              =
         i_tab_raw_data             = tab_raw_data
    *   I_FILENAME                 =
         i_totalsize                = 10000
       tables
         i_tab_converted_data       = l_xml_table
    * 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.

  • Xlm to append itab

    Hi  Experts,
    I use 4.6c SAP. I want to get xml from x website, after xml to append itab. Now I get success xml from web site by HTTP_GET FM.
    But I dont know xml to append itab process.
    If you have any info and example, pleace help me.
    Thanks.

    Hi;
    I use TEXT_CONVERT_XML_TO_SAP FM. But I get error from FM. Error Message : ALL_FUNCTION_CONFLICT_GEN_TYP.
    My programs code :
    DATA : BEGIN OF ITAB  occurs 0,
           TARIH(10),
          date(10),
           KOD(3),
           CURRENCYCODE(3),
           UNIT(5),
           ISIM(30),
           CURRENCYNAME(30),
           FOREXBUYING(15),
           FOREXSELLING(15),
           BANKNOTEBUYING(15),
           BANKNOTESELLING(15),
           CROSSRATEUSD(10),
           CROSSRATEOTHER(10),
           CROSSRATEEURO(10),
           END OF ITAB.
    CALL FUNCTION 'HTTP_GET'
         EXPORTING
              ABSOLUTE_URI                =
              'http://www.tcmb.gov.tr/kurlar/201007/15072010.xml'
             RFC_DESTINATION             = DEST
             USER                        = USER
             PASSWORD                    = PASSWORD
              BLANKSTOCRLF                = 'Y'
         IMPORTING
              STATUS_CODE                 = STATUS
              STATUS_TEXT                 = STATUSTEXT
              RESPONSE_ENTITY_BODY_LENGTH = RLENGTH
         TABLES
              RESPONSE_ENTITY_BODY        = RESPONSE
              RESPONSE_HEADERS            = RESPONSE_HEADERS.
    CALL FUNCTION 'TEXT_CONVERT_XML_TO_SAP'
      EXPORTING
      I_FIELD_SEPERATOR          = ';'*
      I_LINE_HEADER              =*
        I_TAB_RAW_DATA             = ?
      I_FILENAME                 =*
        I_TOTALSIZE                = 3
      TABLES
        I_TAB_CONVERTED_DATA       = ?
    EXCEPTIONS*
      CONVERSION_FAILED          = 1*
      OTHERS                     = 2*

  • Function module to read xml files from application server

    Hi experts,
            I need to read  xml files from application server to sap. Is the any siutable function moldule for that?

    Hi Cenosure,
    Donno about FM which will upload data directly to SAP, I think you have to do some mapping for it so that it will suit the SAP format. Again it depends on your requirement..
    Please elaborate more about your requirement.
    Please have a look on below FM
    TEXT_CONVERT_XML_TO_SAP
    Also search on SCN there are many threads on the same topic available.
    http://abapreports.blogspot.com/2008/09/upload-xml-file-from-application-server.html
    This is the link which will give you the Code
    http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XML_TO_ABAP_46C.html
    Use this XML file to Upload the same, this Program will work for your XML file also,
    http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/input_xml.xml
    See the below thread also
    Upload XML to internal table and vice versa in SAP 4.6C
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

Maybe you are looking for

  • Feedback for my site

    Greetings! I am hoping tha some of the wonderful people here will be willing to provide feedback on my site. I've been working on it for a while and need an outside opinion. Savor Camden Thanks!!! Flat Panel iMac & 14 iBook   Mac OS X (10.4.1)   Flat

  • No wifi network connection

    i have ipod 3rd gen touch..i can not connect to wifi...no network connections show up and the searching circle just continues to go around and around as if it is still searching it doesn't stop or produce results..if i attempt to join another network

  • Problem in audio conferencing using Flex and FMS3.0

    Hi Everyone, I am trying to achieve audio conferencing using Flex and FMS3.0 Currently I am following an approach where all the persons in voice conference publish their voice on flash media server using NetStream.Publish() function and all persons l

  • Why content of a vector element changes when new element added

    in my program, i instantiate 2 Vector objects. one is TV(temporary vector), the other one is V. they all get instances of Class vElement as elements to them(of course, casted to Object first). Class vElement only cantains an int n, an int[] array. i

  • UK Print Image Quality

    Hi their I know the US has a really great print quality to their books but over here in the UK we have a different company for the iphoto books, where by you have to adjust every picture to the adobe RGB space or risk having every picture print reall