SDIXML_DOM_TO_DATA

hi,
I'm trying to convert an xml file to an internal table. in the process, i'm stuck with the function module "SDIXML_DOM_TO_DATA".
Can anyone help me out in using this FM..?
Regards,
Satish.S

Hi,
Check this Report....
report z.
type-pools truxs.
data: it_table like t001 occurs 0.
data: l_dom TYPE REF TO IF_IXML_ELEMENT,
m_document TYPE REF TO IF_IXML_DOCUMENT,
m_xmldoc TYPE REF TO CL_XML_DOCUMENT,
g_ixml TYPE REF TO IF_IXML,
l_iref_pstreamfactory TYPE REF TO if_ixml_stream_factory,
l_iref_postream TYPE REF TO if_ixml_ostream,
It_CONVERTED_DATA TYPE TRUXS_XML_TABLE,
it_converted_line like line of It_CONVERTED_DATA,
w_result TYPE I,
w_rc like sy-subrc,
s_node type string.
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.
**** creating object XML doc ****
write: / 'creating XML document:'.
create object m_xmldoc.
check not m_xmldoc is initial.
write 'ok'.
write: / 'getting XML from DOM:'.
w_rc = m_xmldoc->create_with_dom( document = m_document ).
if w_rc is initial. write 'ok'.
else. write: 'Err =', w_rc.
endif.
**** visualize object XML doc **************
write: / 'displaying XML document:'.
call method m_xmldoc->display.
write: / 'select node from XML document:'.
s_node = m_xmldoc->call_f4( ).
write s_node.
**** convert DOM to XML doc (table) ****
**** method 2 - OO ****
write: / 'creating stream factory:'.
l_iref_pstreamfactory = g_ixml->create_stream_factory( ).
check not l_iref_pstreamfactory is initial.
write 'ok'.
write: / 'creating ostream table:'.
l_iref_postream = l_iref_pstreamfactory->create_ostream_itable(
table = it_converted_data ).
check not l_iref_postream is initial.
write 'ok'.
write: / 'rendering (filling table):'.
CALL METHOD m_document->render( ostream = l_iref_postream ).
* -- how many bytes were written to the table?
w_result = l_iref_postream->get_num_written_raw( ).
write: / w_result, 'bytes were written to the table:'.
loop at it_converted_data into it_converted_line.
write it_converted_line-data.
endloop.
write: / 'end of processing'.
* end of code
Reward points if useful.... (Don't forget)
Regards
AK

Similar Messages

  • Function Modules for XML

    Hi Everyone,
    Can anyone please suggest me if there are any function modules in SAP R/3 which can be used or further modified to retrieve the data from an external XML files.
    Any suggestions or ideas are more welcome.
    Thanks,
    Prashant.

    Hi Prashanth,
    See the below function modules:-
    <b>SDIXML_DATA_TO_DOM -></b>   Convert SAP data(elementary/structured/table types) into DOM (XML)  ExampleO 
    <b>SDIXML_DOM_TO_XML -></b>   Convert DOM (XML) into string of bytes that can be downloaded to PC or application server 
    <b>SDIXML_DOM_TO_SCREEN -></b>   Display DOM (XML) 
    <b>SDIXML_DOM_TO_DATA</b> 
    and also see the below thred, it is having example program also
    /people/gregor.wolf3/blog/2005/12/30/sdn-points-blow-out-chart-sdn-forum-users-online
    Regards
    Sudheer

  • Reading XML file using BAPI and then uploading that xml file data into SAP

    I am getting a xml file from Java server. I need to take
    data from this file using BAPI and need to upload into SAP using SAP.
    Please tell me how to read XML files using BAPI's.

    <b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML
    <b>SDIXML_DOM_TO_XML</b>  Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
    <b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
    <b>SDIXML_DOM_TO_DATA</b>
    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
    Hope this will be useful.
    regards
    vinod

  • XML to complex/deep ABAP structure

    Has anyone successfully used Function module
    SDIXML_DOM_TO_DATA (& related SDIXML* Function modules) to convert XML string into complex ABAP structure?
    I am using WAS 6.40 (ECC) and I was hoping that if the XML & the ABAP structure you pass as function module parameter do match in strcture, then this Function module should automatically convert (ie, de-serialize) the XML into ABAP structure - Without having to write any XSLT or ST (Simple Transformation) files !
    Any ideas? Any other Function module? The ABAP structure I want to be populated is a "deep structure" with many levels and tables at various levels etc..
    Thanks a lot

    Hi Janet Lam,
    Here's an article explaining mapping between XML and ABAP structures.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/2e98a690-0201-0010-3b90-cda224bad152
    Dont forget to reward pts, if it helps ;>)
    Regards,
    Rakesh.

  • 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

  • Getting XML info with ABAP mapping

    Hi everyone.
    I'm near to finish my abap mapping demo. The problem is that i don't know how i can retrieve the values of a kind of node.
    I would like to retrieve this data into a internal table. I've done the output XML.
    How can i get that values from SOURCE parameter into an internal table?
    Regards.

    Hi!
    First of all you have a little bit of XML parsing to do using the SIXML package in ABAP (see example reports in same dev class).
    Then you can travers your "document" with methods like
    get_elements_by_tag_name or get_root_element.
    There are also 2 function modules to convert a document into an ABAP internal table.
    SDIXML_DATA_TO_DOM and SDIXML_DOM_TO_DATA.
    Regards
    Michael

Maybe you are looking for

  • Itunes error when downloading album err=-100008

    Hello.. I almost finished downloading a well anticipated album. All songs downloaded except 1. I keep getting the error above, and when i check purchases it starts but then continues to give me the msg error . Unable to finish download of Song, the f

  • Sender Soap Axis error in PI 7.31

    Hi Experts, We are using PI7.31 We got a requirement to extract XML from a exchange rate URL on daily basis and send it to ECC from PI. I followed the below link to configure the sender SOAP Axis channel. http://scn.sap.com/community/pi-and-soa-middl

  • What download is good for Firefox 33 for silent install for windows os?

    In fire Fox 33 download we see there is setup stub .exe , when will setup.exe for firefox 33 be available as we cannot do a silent install for setup stub.exe . we have no issues in doing silent install for setup .exe which we had for previous version

  • Listener and environment files are not created in New RDBMS ORACLE_HOME

    Hi, I am upgrading the EBS 12.1.3 database from 11.1.0.7 to 11.2.0.2. I have completed the steps till Implement and run AutoConfig on Interoperability Notes EBS R12 with Database 11gR2 [ID 1058763.1] I have completed AutoConfig on the Database tier s

  • "AT END OF" in Class Programming

    Hi, I want to know how to handle the following situation in ABAP within Class programming, DATA : BEGIN OF LCL_TRAN OCCURS 0,         TRAN TYPE STRING       END OF LCL_TRAN. DATA : BEGIN OF LCL_PROD OCCURS 0,         PROD TYPE STRING,       END OF LC