Function module to read XML file in ABAP

Hey guys
is there any function module which can read an XML file into an ABAP code?
we are getting some file on the application server in XML format and we need to read this file in ABAP code,how can i achieve this ?
thanz
ahmad

Hi Ahmad,
  These are few functions to work with XML in ABAP.
  SDIXML_DATA_TO_DOM: Convert SAP data (elementary/structured/table types) into DOM (XML)       
SDIXML_DOM_TO_XML: Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
SDIXML_DOM_TO_SCREEN: Display DOM (XML)
SDIXML_DOM_TO_DATA
Example of using these:
eport z.
data: it_table like t001 occurs 0.
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.
start-of-selection.
  select * from t001 into table it_table.
end-of-selection.
initialize iXML-Framework          ****
  write: / 'initialiazing iXML:'.
  class cl_ixml definition load.
  g_ixml = cl_ixml=>create( ).
  check not g_ixml is initial.
  write: 'ok'.
create DOM from SAP data           ****
  write: / 'creating iXML doc:'.
  m_document = g_ixml->create_document( ).
  check not m_document is initial.
  write: 'ok'.
  write: / 'converting DATA TO DOM 1:'.
  CALL FUNCTION 'SDIXML_DATA_TO_DOM'
    EXPORTING
      NAME               = 'IT_TABLE'
      DATAOBJECT         = it_table[]
    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.
  write: / 'appending DOM to iXML doc:'.
  w_rc = m_document->append_child( new_child = l_dom ).
  if w_rc is initial.  write  'ok'.
  else.                write: 'Err =', w_rc.
  endif.
visualize iXML (DOM)               ****
  write: / 'displaying DOM:'.
  CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
    EXPORTING
      DOCUMENT          = m_document
    EXCEPTIONS
      NO_DOCUMENT       = 1
      OTHERS            = 2.
  if sy-subrc = 0.  write  'ok'.
  else.             write: 'Err =', sy-subrc.
  endif.
convert DOM to XML doc (table)     ****
  write: / 'converting DOM TO XML:'.
  CALL FUNCTION 'SDIXML_DOM_TO_XML'
    EXPORTING
      DOCUMENT            = m_document
    PRETTY_PRINT        = ' '
    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.
  write: / 'XML as string of size:', w_size, / w_string.
  describe table it_xml lines w_result.
  write: / 'XML as table of', w_result, 'lines:'..
  loop at it_xml into s_xml.
    write s_xml.
  endloop.
  write: / 'end of processing'.
end of code
Let me know if you have further questions..
BR
Rakesh

Similar Messages

  • Function module to read xml file

    Hi
    Can anyone help me with using function module to read the xml file into SAP. Any ideas! Any help!
    Thanks

    Found a note, but not very helpful
    Note 877328 - SE37: Error when generating the test frame

  • 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

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

  • Reading XML file to ABAP internal table

    Hi all,
    Iam trying to convert a XLM file into abap internal table , am using XSLT transformation to parse the XML file and i am using "CALL METHOD cl_gui_frontend_services=>gui_upload" for reading the XML file.
    below is the XML file.
    ===========================================================================
    - <PIXBridge version="2.2" timestamp="2003-04-09T15:27:00">
    - <PIX>
      <TransactionType>605</TransactionType>
      <TransactionCode>98</TransactionCode>
      <TransactionNumber>6888965</TransactionNumber>
      <SequenceNumber>40001</SequenceNumber>
    - <SKUDefinition>
      <Company>GZL</Company>
      <Division>BMD</Division>
      <Season />
      <SeasonYear />
      <Style>ORT002A</Style>
      <StyleSuffix />
      <Color>K13</Color>
      <ColorSuffix />
      <SecDimension />
      <Quality />
      <SizeRangeCode />
      <SizeDesc>M</SizeDesc>
      <SkuID>200140577</SkuID>
      </SKUDefinition>
      </PIX>
      </PIXBridge>
    =================================================================
    and my Transformation code is as below
    <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>
            <IPIX>
              <xsl:apply-templates select="//PIX"/>
            </IPIX>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="PIX">
        <item>
          <TRANSACTIONTYPE>
            <xsl:value-of select="TransactionType"/>
          </TRANSACTIONTYPE>
          <TRANSACTIONCODE>
            <xsl:value-of select="TransactionCode"/>
          </TRANSACTIONCODE>
          <TRANSACTIONNUMBER>
            <xsl:value-of select="TransactionNumber"/>
          </TRANSACTIONNUMBER>
          <SEQUENCENUMBER>
            <xsl:value-of select="SequenceNumber"/>
          </SEQUENCENUMBER>
          <SKUDEFINITION>
            <COMPANY>
              <xsl:value-of select="Company"/>
            </COMPANY>
            <DIVISION>
              <xsl:value-of select="Division"/>
            </DIVISION>
            <SEASON/>
            <SEASONYEAR/>
            <STYLE>
              <xsl:value-of select="Style"/>
            </STYLE>
            <STYLESUFFIX/>
            <COLOR>
            <xsl:value-of select="Color"/>
            </COLOR>
            <COLORSUFFIX/>
            <SECDIMENSION/>
            <QUANTITY/>
            <SIZERANGECODE/>
            <SIZEDESC>
              <xsl:value-of select="SizeDesc"/>
            </SIZEDESC>
            <SKUID>
              <xsl:value-of select="SkuID"/>
            </SKUID>
          </SKUDEFINITION>
          </item>
        </xsl:template>
    When i run my program i am getting the values only till the sequence number part and im not getting any values  that is read in between <SKUDEFINITION> ..... </SKUDEFINITION>
    I need help to sort this , kindly help me in this.
    regs,
    raja

    I am not able to get a clue out of that, can Get Durairaj Athavan Raja in to loop for sorting this out.
    I made changes to my transformation program , but still not getting the output of the components inside the
    <SKUDefinition> , but when i debug  the transformation i can able to see the output values for those components but when i get the values in the result table im not getting values of those components.
    <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>
            <IPIX>
              <xsl:apply-templates select="//PIX"/>
            </IPIX>
          </asx:values>
        </asx:abap>
      </xsl:template>
      <xsl:template match="PIX">
        <item>
          <TRANSACTIONTYPE>
            <xsl:value-of select="TransactionType"/>
          </TRANSACTIONTYPE>
          <TRANSACTIONCODE>
            <xsl:value-of select="TransactionCode"/>
          </TRANSACTIONCODE>
          <TRANSACTIONNUMBER>
            <xsl:value-of select="TransactionNumber"/>
          </TRANSACTIONNUMBER>
          <SEQUENCENUMBER>
            <xsl:value-of select="SequenceNumber"/>
          </SEQUENCENUMBER>
          <xsl:for-each select="SKUDefinition">
          <SKUDEFINITION>
          <COMPANY>
              <xsl:value-of select="Company"/>
          </COMPANY>
          <DIVISION>
              <xsl:value-of select="Division"/>
          </DIVISION>
          <SEASON/>
          <SEASONYEAR/>
          <STYLE>
            <xsl:value-of select="Style"/>
          </STYLE>
          <STYLESUFFIX/>
          <COLOR>
            <xsl:value-of select="Color"/>
          </COLOR>
          <COLORSUFFIX/>
          <SECDIMENSION/>
          <QUANTITY/>
          <SIZERANGECODE/>
          <SIZEDESC>
              <xsl:value-of select="SizeDesc"/>
          </SIZEDESC>
          <SKUID>
              <xsl:value-of select="SkuID"/>
          </SKUID>
          </SKUDEFINITION>
          </xsl:for-each>
        </item>
      </xsl:template>
    </xsl:transform>
    ==================
    Below is my main program
    ===================
    TYPE-POOLS abap.
    CONSTANTS gs_file TYPE string VALUE 'C:\XMLABAP1.xml'.
    This is the structure for the data from the XML file
    TYPES: BEGIN OF ty_text,
             TransactionType(3) type n,
             TransactionCode(2) type n,
             TransactionNumber(7) type n,
             SequenceNumber(5) type n,
             Company(3) type c,
             Division(3) type c,
             Season(3) type c,
             SeasonYear(4) type c,
             Style(8) type c,
             Color(3) type c,
             SecDimension(3) type c,
             Quality(3) type n,
             SizeRangeCode(2) type c,
             SizeDesc(1) type c,
             SkuID(10) type c,
           END OF ty_text.
    Table for the XML content
    DATA: gt_itab       TYPE STANDARD TABLE OF char2048.
    data: xmlstr        TYPE XSTRING.
    Table and work ares for the data from the XML file
    DATA: gt_person     TYPE STANDARD TABLE OF ty_text,
          gs_person     TYPE ty_text.
    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
    "IPERSON".
    GET REFERENCE OF gt_person INTO gs_result_xml-value.
    gs_result_xml-name = 'IPIX'.
    APPEND gs_result_xml TO gt_result_xml.
    Perform the XSLT stylesheet
    TRY.
        CALL TRANSFORMATION ZAUM_MANH_SYNC_RPT
        SOURCE XML XMLSTR
        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.
    Now let's see what we got from the file
    LOOP AT gt_person INTO gs_person.
    WRITE: / 'Transaction Type:', gs_person-TransactionType.
      WRITE: / 'Transaction Code :', gs_person-TransactionCode.
      WRITE: / 'Transaction Number :', gs_person-TransactionNumber.
       WRITE: / 'SequenceNumber :', gs_person-SequenceNumber.
       WRITE: / 'Company : ', gs_person-Company.
      WRITE : /.
    ENDLOOP. "gt_person.

  • Reading XML files into ABAP

    Hello folks,
    I've been struggling and I need to figure out how to read a field from an XML field into ABAP. I'm writing this method and I need to call this field from my XML file. Can you guys please give me suggestions? Please advise. I will appreciate your time. Thanks in advance.
    Ol.

    *& Report z_xit_xml_check
    report z_xit_xml_check.
    class cl_ixml definition load.
    type-pools: ixml.
    types: begin of t_xml_line,
    data(256) type x,
    end of t_xml_line,
    begin of tsfixml,
    data(1024) type c,
    end of tsfixml.
    data: l_ixml type ref to if_ixml,
    l_streamfactory type ref to if_ixml_stream_factory,
    l_parser type ref to if_ixml_parser,
    l_istream type ref to if_ixml_istream,
    l_document type ref to if_ixml_document,
    l_node type ref to if_ixml_node,
    l_xmldata type string.
    data: l_elem type ref to if_ixml_element,
    l_root_node type ref to if_ixml_node,
    l_next_node type ref to if_ixml_node,
    l_name type string,
    l_iterator type ref to if_ixml_node_iterator.
    data: l_xml_table type table of t_xml_line,
    l_xml_line type t_xml_line,
    l_xml_table_size type i.
    data: l_filename type string.
    parameters: pa_file type char1024 default
    'd:\joao\desenvolvimentos\fi\fact\teste.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.
    data: name2 type string,
    name_root type string,
    node_parent type ref to if_ixml_node,
    node_root type ref to if_ixml_node,
    num_children type i.
    node ?= document.
    check not node is initial.
    uline.
    write: /.
    write: /' DOM-TREE'.
    write: /.
    if node is initial. exit. endif.
    create a node iterator
    iterator = node->create_iterator( ).
    get current node
    node = iterator->get_next( ).
    loop over all nodes
    while not node is initial.
    indent = node->get_height( ) * 2.
    indent = indent + 20.
    num_children = node->num_children( ).
    case node->get_type( ).
    when if_ixml_node=>co_node_element.
    element node
    name = node->get_name( ).
    nodemap = node->get_attributes( ).
    node_root = node->get_root( ).
    name_root = node_root->get_name( ).
    write: / 'ELEMENT :'.
    write: at indent name color col_positive inverse.
    write: 'NUM_CHILDREN:', num_children.
    write: 'ROOT:', name_root.
    node_parent = node->get_parent( ).
    name2 = node_parent->get_name( ).
    write: 'NAME2: ' , name2.
    if not nodemap is initial.
    attributes
    count = nodemap->get_length( ).
    do count times.
    index = sy-index - 1.
    attr = nodemap->get_item( index ).
    name = attr->get_name( ).
    prefix = attr->get_namespace_prefix( ).
    value = attr->get_value( ).
    write: / 'ATTRIBUTE:'.
    write: at indent name color col_heading inverse, '=',
    value color col_total inverse.
    enddo.
    endif.
    when if_ixml_node=>co_node_text or
    if_ixml_node=>co_node_cdata_section.
    text node
    value = node->get_value( ).
    write: / 'VALUE :'.
    mjprocha
    node_parent = node->get_parent( ).
    write: at indent value color col_group inverse.
    name2 = node_parent->get_name( ).
    write: 'NAME2: ' , name2.
    endcase.
    advance to next node
    node = iterator->get_next( ).
    endwhile.
    endform. "process_dom

  • Reading .xml file in ABAP

    Hi All,
    I am trying to read a xml file which is as follows:
    Please suggest a way with which i can do this
    Thanks & Regards,
    Jignesh.
    Edited by: jignesh malde on Mar 26, 2009 2:00 PM

    Hi Jignesh,
    For reading an xml file into an program u have to create transformation program for that xml.
    Tcode for creating xml transformation is STRANS.
    Chk this links once
    Help with ABAP Structure to XML - Simple Transformation
    Simple XML Transformation: Dump on converting several elements into xstring
    Regards,
    Lakshman

  • Read XML file to ABAP

    Hi All
    I need to read the XML file directly and do the further processing.
    Please let me know, if anybody have worked on the same
    Regards
    Madhan Doraikannan

    Hi, an additional question to you.
    Which version server you run your application on?
    I want to know this because as I know there is two way to read XML to ABAP. And a way in XLST is only be supported by 4.7(6.2) or above.
    And a classical way is though DOM by iXML interface.(you can find some resource in help.sap.com, just search word 'ixml')
    Hope it will be helpful.

  • Function module to download XML file to local file

    Hello Friends,
    I have an XML string,is there a function module,which helps me in
    downloading this XML string as an XML file ,to local disk.
    regards
    kaushik

    Hello Kaushik
    Define an itab of TYPE string, append your single XML string and download the itab using method GUI_DOWNLOAD of class CL_GUI_FRONTEND_SERVICES.
    DATA:
      lt_xml  TYPE TABLE OF string.
      APPEND ld_xml TO lt_xml.
      CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
        EXPORTING
    Regards,
      Uwe

  • Reading XMl file from ABAP

    Hi friends,
    I am working in SAP 4.6c. Please help me in the following scenario.
    I have to read the xml whixjh in the application server.
    I have to Make sure each XML only contains 1 IDOC.  If 10 idocs are pushed out , there should be 10 XML messages.  1 idoc per XML.
    So if the FM receives a message that contains 10 idocs, the routine just needs to split the XML into 10 separate XML's using YYYYMMDDHHMMSS_IDOCNUMBER.XML as the new of each XML.
    Convert the XML into UTF-8 compliant
    above is my requirement.
    Can you guide me how to read a XMl file and findout how many idocs are present in that...
    Please guide me...
    Thanks in advance,
    Sudha

    Hi Sudha,
    Refer this blog and thread to get more information on how to process XML documents.
    /people/thomas.jung3/blog/2004/06/24/bsp-150-a-developer146s-journal-part-v-xml-for-rfcs
    redaing an XML file to an internal table
    Regards,
    Uma
    Message was edited by: Uma Maheswari

  • Read xml file in abap

    hi experts ,
       how  to upload a given xml file into sap. any simple code.
                                                                         prakash.

    Hi,
    If you want to upload the XML file and you have the ABAP proxy generated,then
    you could use the sproxy transaction and select the namespace and interface for which you want to execute the XML file.
    Best Regards,
    Arun

  • A need a function module to read a file and write back into it

    Hello ,
    My requirement is to provide the path to a file , read the file contents and then write back to it.
    Thanks,
    Mridu.

    Hi ,
    Use combination of these three FM's , A nice documentation is given for them by SAP .
    1.)  F4_FILENAME
    2.) GUI_UPLOAD
    3.) GUI_DOWNLOAD
    revert back if any queries
    reward points if helpful

  • FM to read XML files from Application server in ECC5.0

    Hi All,
    We need to pick up an XML file from Application server/FTP server. The requirement is to parse the XML file and process it to create material master. SAP provides standard function modules to read XML files.
    Now we need to read the XML file contents of MM01 and upload into SAP Data Base through BAPI
    I need to know about the Function modules to read XML files from Application Server and also about the FM's that will update the Date base tables with the data obtained form XML files.
    Regards
    Prathima

    Parsing XML data:
    http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
    or alternatively check out ABAP online help for "CALL TRANSFORMATION".
    For creating the material master look at BAPI_STANDARDMATERIAL_CREATE.
    Thomas

  • Function module to read Comma Seperated File (CSV)

    Hi,
    Is there any Function module to read CSV file from presentation server or Application server?
    Regards,
    Madhu

    Hi madhukeshwar,
    1. Exactly for this purpose,
    i have developed an independent FORM
    where we give inputs
    a) file name (eg. abcd.txt)
    b) separator (eg , COMMA in your case)
    c) internal table (eg. t001)
    2. It will provide the data
    in proper format
    (no matter what the separator)
    (it can work with any kind of separator)
    3. just copy paste in new program.
    REPORT abc.
    change your table declaration and file name
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    PERFORM myupload TABLES t001 USING 'd:\t001.txt' ','.
    BREAK-POINT.
    in debug see t001
    INDEPENDENT FORM
    FORM myupload TABLES orgtab
    USING filename separator.
    Data
    DATA : BEGIN OF itab OCCURS 0,
    myline(1000) TYPE c,
    END OF itab.
    DATA : extension(5) TYPE c.
    DATA : name(100) TYPE c.
    DATA : newfilename TYPE string.
    Step 1
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = filename
    TABLES
    data_tab = itab.
    Step 2
    LOOP AT itab.
    REPLACE ALL OCCURRENCES OF separator IN itab-myline WITH
    cl_abap_char_utilities=>horizontal_tab.
    MODIFY itab.
    ENDLOOP.
    Step 3
    DATA : path LIKE pcfile-path.
    path = filename.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    extension = extension
    name = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    invalid_drive = 1
    invalid_extension = 2
    invalid_name = 3
    invalid_path = 4
    OTHERS = 5
    Step 4
    newfilename = filename.
    REPLACE name IN newfilename WITH 'temp'.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE =
    filename = newfilename
    TABLES
    data_tab = itab
    FIELDNAMES =
    Step 5
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = newfilename
    has_field_separator = 'X'
    TABLES
    data_tab = orgtab.
    ENDFORM. "myupload
    3.
    regards,
    amit m.

  • Function Module To read all the Files in a Given UNIX directory.

    Can anyone provide me with a FUNCTION MODULE which reads all the files available in a UNIX directory?
    I have the UNIX directory given. I need to find all the files available in that particular Directory so that I can choose and process accordingly. Probably I can store all files in an Internal Table.
    Thanks in advance.
    Sunil

    Hi Nick,
    Thankyou very much for the response.
    The Function Module /SAPDMC/LSM_F4_SERVER_FILE is interactive wherein we can select only one file.
    But my requirement is I need to collect (probably in an internal table) all the files exixting in the given UNIX directory.
    Can you please find in that direction. I would be very grateful.
    Thanks.
    Sunil

Maybe you are looking for