<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: XML to Internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697045#M305732</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check this. is this what you are looking for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ycombindxml
       NO STANDARD PAGE HEADING.

DATA: flights TYPE STANDARD TABLE OF sflight ,
      booking TYPE STANDARD TABLE OF bookings .

DATA: f_xml TYPE string ,
      b_xml TYPE string ,
      fb_xml TYPE string .

REFRESH: flights, booking .

SELECT * UP TO 10 ROWS FROM sflight INTO TABLE flights .
SELECT * UP TO 5 ROWS FROM bookings INTO TABLE booking .

CLEAR : f_xml, b_xml, fb_xml .

CALL TRANSFORMATION (`ID`)
         SOURCE flights   = flights[]
         RESULT XML f_xml.

CALL TRANSFORMATION (`ID`)
         SOURCE booking   = booking[]
         RESULT XML b_xml.

CALL TRANSFORMATION (`ID`)
         SOURCE xmlf = f_xml
                xmlb =  b_xml
         RESULT XML fb_xml.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Nov 2006 06:12:56 GMT</pubDate>
    <dc:creator>athavanraja</dc:creator>
    <dc:date>2006-11-29T06:12:56Z</dc:date>
    <item>
      <title>XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697043#M305730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have checked most of the threads on this topic however was'nt able to figure out how I could implement in my scenario.&lt;/P&gt;&lt;P&gt;I have two XMl files of IDOC type, now i have to write a program to combine both these XML's into one XML file.I have no Knowledge of XSLT  and iXML, could anybody help me on this  please points would be rewarded for sure...thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 10:08:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697043#M305730</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-28T10:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697044#M305731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i don´t no what your question "XML to Internal table" as in common with "how to merge two IDOCs", but i guess you will merge the to xml documents (idocs) at first before you`ll transform it to an abap internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My proposal is to use the ixml library to merge the two idocs and a xslt-program to transform the xml to abap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here some code which will help you to merge the two xml files. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I mentioned that you have the idocs as an xstring ( variable iv_doc_1 and iv_doc_2 ). The source could be also a string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For further infos look at this help.sap.com link&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/47/b5413acdb62f70e10000000a114084/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/47/b5413acdb62f70e10000000a114084/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA: lr_ixml                TYPE REF TO if_ixml,
      lr_ixml_doc_1          TYPE REF TO if_ixml_document,
      lr_ixml_doc_2					 TYPE REF TO if_ixml_document,
      lr_ixml_doc_out				 TYPE REF TO if_ixml_document,
      lr_ixml_stream_factory TYPE REF TO if_ixml_stream_factory,
      lr_ixml_istream        TYPE REF TO if_ixml_istream,
      lr_ixml_parser         TYPE REF TO if_ixml_parser,
      lr_ixml_new_root       type ref to if_ixml_element,
      lr_ixml_root_1				 type ref to if_ixml_element,
      lr_ixml_root_2				 type ref to if_ixml_element,
      lp_value               type string.
 
* create ixml factory
lr_ixml                = cl_ixml=&amp;gt;create( ).

* create ixml documents for idocs and one for output
lr_ixml_doc_1          = lr_ixml-&amp;gt;create_document( ).
lr_ixml_doc_2          = lr_ixml-&amp;gt;create_document( ).
lr_ixml_doc_out		     = lr_ixml-&amp;gt;create_document( ).

* create stream factory
lr_ixml_stream_factory = lr_ixml-&amp;gt;create_stream_factory( ).
 
* create input streams for idoc 1 and idoc 2
lr_ixml_istream_1 = lr_ixml_stream_factory-&amp;gt;create_istream_xstring( iv_idoc_1 ).
lr_ixml_istream_2 = lr_ixml_stream_factory-&amp;gt;create_istream_xstring( iv_idoc_2 ).

* create xml parser to parse idoc 1 
lr_ixml_parser = lr_ixml-&amp;gt;create_parser( document       = lr_ixml_doc_1
                                         istream        = lr_ixml_istream_1
                                         stream_factory = lr_ixml_stream_factory ).
 
* parse idoc 1
lr_ixml_parser-&amp;gt;parse( ).

* create xml parser to parse idoc 2
lr_ixml_parser = lr_ixml-&amp;gt;create_parser( document       = lr_ixml_doc_2
                                         istream        = lr_ixml_istream_2
                                         stream_factory = lr_ixml_stream_factory ).
 
 * parse idoc 2
lr_ixml_parser-&amp;gt;parse( ).


* create a root node in the output document
lr_ixml_new_root = lr_ixml_doc_out-&amp;gt;create_element( name ='Merged' ).
lr_ixml_doc_out-&amp;gt;append_child( lr_ixml_new_root ).

* determine the root nodes of the idocs
lr_ixml_root_1 = lr_ixml_doc_1-&amp;gt;get_root_element( ).
lr_ixml_root_2 = lr_ixml_doc_2-&amp;gt;get_root_element( ).

* append the root node to the new root node
lr_ixml_new_root-&amp;gt;append_child( lr_ixml_root_1 ).
lr_ixml_new_root-&amp;gt;append_child( lr_ixml_root_2 ).

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the two idocs should be merged in lr_ixml_doc_out.&lt;/P&gt;&lt;P&gt;Now, you can write a xslt program which transform the ixml-dom object&lt;/P&gt;&lt;P&gt;into a internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

data: lr_result type table of z_my_structure. 

* transform xml source to internal table
CALL TRANSFORMATION 'Z_MYIDOCS_TO_ABAP'
	SOURCE XML lr_ixml_doc_out
	RSULT ITAB = lt_result
.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to write a XSLT program look a this &lt;A href="http://help.sap.com/saphelp_47x200/helpdata/en/fd/9d7348389211d596a200a0c94260a5/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_47x200/helpdata/en/fd/9d7348389211d596a200a0c94260a5/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also the weblog of Tobias Trapp will help you to transform the xml source to abap with XSLT.&lt;/P&gt;&lt;P&gt;/people/tobias.trapp/blog/2006/10/06/xml-processing-in-abap-part-9-150-abap-processing-using-xslt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2006 22:39:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697044#M305731</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-28T22:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697045#M305732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check this. is this what you are looking for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ycombindxml
       NO STANDARD PAGE HEADING.

DATA: flights TYPE STANDARD TABLE OF sflight ,
      booking TYPE STANDARD TABLE OF bookings .

DATA: f_xml TYPE string ,
      b_xml TYPE string ,
      fb_xml TYPE string .

REFRESH: flights, booking .

SELECT * UP TO 10 ROWS FROM sflight INTO TABLE flights .
SELECT * UP TO 5 ROWS FROM bookings INTO TABLE booking .

CLEAR : f_xml, b_xml, fb_xml .

CALL TRANSFORMATION (`ID`)
         SOURCE flights   = flights[]
         RESULT XML f_xml.

CALL TRANSFORMATION (`ID`)
         SOURCE booking   = booking[]
         RESULT XML b_xml.

CALL TRANSFORMATION (`ID`)
         SOURCE xmlf = f_xml
                xmlb =  b_xml
         RESULT XML fb_xml.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Nov 2006 06:12:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697045#M305732</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2006-11-29T06:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697046#M305733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey Thx Experts, for all the inputs,&lt;/P&gt;&lt;P&gt;i would try and implement this and hope it works if any problem i shall get back for ur help, thanks a lot again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 06:48:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697046#M305733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T06:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697047#M305734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Experts,&lt;/P&gt;&lt;P&gt;I am trying to fetch the two XMl files from the App Server, So i would be using OPEN DATASET,&lt;/P&gt;&lt;P&gt;So how would i Be assigning the two strings Str1 (type:Xstring)and Str2 (type:Xstring) to lr_ixml_doc_1 &amp;amp; lr_ixml_doc_2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any thing i need to specially consider here...? please help..!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 07:22:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697047#M305734</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T07:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697048#M305735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;replace in the following lines iv_idoc_1 by Str1 and iv_idoc_2 by Str2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
lr_ixml_istream_1 = lr_ixml_stream_factory-&amp;gt;create_istream_xstring( iv_idoc_1 ).
lr_ixml_istream_2 = lr_ixml_stream_factory-&amp;gt;create_istream_xstring( iv_idoc_2 ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 08:20:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697048#M305735</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T08:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697049#M305736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks Sebastin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STR1 and STR2 are of STRING not XSTRING type, so i have changed the following code, is it correct &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lr_ixml_istream_1 = lr_ixml_stream_factory-&amp;gt;create_istream_string( STR1).&lt;/P&gt;&lt;P&gt;lr_ixml_istream_2 = lr_ixml_stream_factory-&amp;gt;create_istream_string( STR2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have changed "create_istream_xstring" to "create_istream_string" i hope thats the way we do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and is there anything else i need to change....? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It did not give me an error though, need your suggestions on this. thanks for all ur help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 11:15:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697049#M305736</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T11:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: XML to Internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697050#M305737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello andrew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thats all you have to chance. to see or test the merged xml docs append the following lines to your report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data: lr_ixml_ostream   type ref to if_ixml_ostream,&lt;/P&gt;&lt;P&gt;        lr_ixml_stream_factory TYPE REF TO if_ixml_stream_factory,&lt;/P&gt;&lt;P&gt;        lr_ixml_renderer type ref to if_ixml_renderer,&lt;/P&gt;&lt;P&gt;        lp_xml_out       type string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lr_ixml_ostream = lr_ixml_stream_factory-&amp;gt;create_ostream_cstring( importing string = lp_xml_out ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lr_ixml_renderer = lr_ixml-&amp;gt;create_renderer( ostream  = lr_ixml_ostream&lt;/P&gt;&lt;P&gt;                                               document = lr_ixml_doc_out ).&lt;/P&gt;&lt;P&gt;                                               &lt;/P&gt;&lt;P&gt;  lr_ixml_renderer-&amp;gt;render( ).                                                                                &lt;/P&gt;&lt;P&gt;write lp_xml_out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Nov 2006 11:53:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/xml-to-internal-table/m-p/1697050#M305737</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-30T11:53:02Z</dc:date>
    </item>
  </channel>
</rss>

