Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Internal Table Data to XML

Former Member
0 Likes
819

Hi

I have a requirement of writing internal table data to XML. Any idea where i should start.

I have pretty good experience with ABAP and basic knowledge in XML.

There are good blogs which talk about transformations and other stuff but they are not able to give me clear path to my solution.

Could somebody give me a basic example or some reference material where i can move the data in internal table (assume Sales order details of a day) to XML.

Thanks

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
695

Refer the program -

In this implementation we will only focus on the creation of the XML file and the transfer to the user. You can not create a XML document directly. You have to use a so called ixml factory first.

TYPE-POOLS: ixml.

DATA: l_ixml TYPE REF TO if_ixml.

l_ixml = cl_ixml=>create( ).

This iXML factory can create an empty XML document object named l_document.

DATA: l_document TYPE REF TO if_ixml_document.

l_document = l_ixml->create_document( ).

At this point you can add the nodes (elements, attributes) into the document. First you have to declare the root element node.

DATA: l_element_root TYPE REF TO if_ixml_element.

This node we have to give a name and add it (create_simple_node) to the document object l_document, which will be the parent of this node.

l_element_root = l_document->create_simple_element(

name = 'flights'

parent = l_document ).

Next we can add child nodes to there parent node using the same method of the document object.

DATA: l_element_airline TYPE REF TO if_ixml_element,

l_element_airline = l_document->create_simple_element(

name = 'airline'

parent = l_element_root ).

An attribute can be add easily using the method set_attribute of the element node.

l_rc = l_element_airline->set_attribute( name = 'code' value = 'LH401' ).

Now we have finished the document object. Regretfully it can not be displayed in any form due to the fact that it is a binary object.

The next step is to convert the created document to a flat file. To achieve this we have to create a stream factory, which will help us to create an output stream.

DATA: l_streamfactory TYPE REF TO if_ixml_stream_factory.

l_streamfactory = l_ixml->create_stream_factory( ).

In this case, we will convert the document into an output stream which is based on an internal table of type x.

TYPES: BEGIN OF xml_line,

data(256) TYPE x,

END OF xml_line.

DATA: l_xml_table TYPE TABLE OF xml_line,

l_xml_size TYPE i,

l_rc TYPE i,

l_ostream TYPE REF TO if_ixml_ostream.

l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).

When we have created the output stream we can do the rendering from the document into the stream. The XML data will be stored in the internal table automatically.

DATA: l_renderer TYPE REF TO if_ixml_renderer.

l_renderer = l_ixml->create_renderer( ostream = l_ostream

& nbsp; document = l_document ).

l_rc = l_renderer->render( ).

In the last step we upload the file to the sapgui

l_xml_size = l_ostream->get_num_written_raw( ).

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

bin_filesize = l_xml_size

filename = 'c:\temp\flights.xml'

filetype = 'BIN'

CHANGING

data_tab = l_xml_table

EXCEPTIONS

OTHERS = 24.

This finished the first step-of-three. As mentioned before the next log will focus on the conversion from xml files (back) to abap tables.

REPORT z_xit_xml_dom_create.

TYPE-POOLS: ixml.

TYPES: BEGIN OF xml_line,

data(256) TYPE x,

END OF xml_line.

DATA: l_ixml TYPE REF TO if_ixml,

l_streamfactory TYPE REF TO if_ixml_stream_factory,

l_ostream TYPE REF TO if_ixml_ostream,

l_renderer TYPE REF TO if_ixml_renderer,

l_document TYPE REF TO if_ixml_document.

DATA: l_element_flights TYPE REF TO if_ixml_element,

l_element_airline TYPE REF TO if_ixml_element,

l_element_flight TYPE REF TO if_ixml_element,

l_element_from TYPE REF TO if_ixml_element,

l_element_to TYPE REF TO if_ixml_element,

l_element_dummy TYPE REF TO if_ixml_element,

l_value TYPE string.

DATA: l_xml_table TYPE TABLE OF xml_line,

l_xml_size TYPE i,

l_rc TYPE i.

DATA: lt_spfli TYPE TABLE OF spfli.

DATA: l_spfli TYPE spfli.

START-OF-SELECTION.

  • Fill the internal table

SELECT * FROM spfli INTO TABLE lt_spfli.

  • Sort internal table

SORT lt_spfli BY carrid.

  • Start filling xml dom object from internal table

LOOP AT lt_spfli INTO l_spfli.

AT FIRST.

  • Creating a ixml factory

l_ixml = cl_ixml=>create( ).

  • Creating the dom object model

l_document = l_ixml->create_document( ).

  • Fill root node with value flights

l_element_flights = l_document->create_simple_element(

name = 'flights'

parent = l_document ).

ENDAT.

AT NEW carrid.

  • Create element 'airline' as child of 'flights'

l_element_airline = l_document->create_simple_element(

name = 'airline'

parent = l_element_flights ).

  • Create attribute 'code' of node 'airline'

l_value = l_spfli-carrid.

l_rc = l_element_airline->set_attribute( name = 'code' value = l_value ).

  • Create attribute 'name' of node 'airline'

SELECT SINGLE carrname FROM scarr INTO l_value WHERE carrid EQ l_spfli-carrid.

l_rc = l_element_airline->set_attribute( name = 'name' value = l_value ).

ENDAT.

AT NEW connid.

  • Create element 'flight' as child of 'airline'

l_element_flight = l_document->create_simple_element(

name = 'flight'

parent = l_element_airline ).

  • Create attribute 'number' of node 'flight'

l_value = l_spfli-connid.

l_rc = l_element_flight->set_attribute( name = 'number' value = l_value ).

ENDAT.

  • Create element 'from' as child of 'flight'

CONCATENATE l_spfli-cityfrom ',' l_spfli-countryfr INTO l_value.

l_element_from = l_document->create_simple_element(

name = 'from'

value = l_value

parent = l_element_flight ).

  • Create attribute 'airport' of node 'from'

l_value = l_spfli-airpfrom.

l_rc = l_element_from->set_attribute( name = 'airport' value = l_value ).

  • Create element 'to' as child of 'flight'

CONCATENATE l_spfli-cityto ',' l_spfli-countryto INTO l_value.

l_element_to = l_document->create_simple_element(

name = 'to'

value = l_value

parent = l_element_flight ).

  • Create attribute 'airport' of node 'from'

l_value = l_spfli-airpto.

l_rc = l_element_to->set_attribute( name = 'airport' value = l_value ).

  • Create element 'departure' as child of 'flight'

l_value = l_spfli-deptime.

l_element_dummy = l_document->create_simple_element(

name = 'departure'

value = l_value

parent = l_element_flight ).

  • Create element 'arrival' as child of 'flight'

l_value = l_spfli-arrtime.

l_element_dummy = l_document->create_simple_element(

name = 'arrival'

value = l_value

parent = l_element_flight ).

  • Create element 'type' as child of 'flight'

CASE l_spfli-fltype.

WHEN 'X'.

l_value = 'Charter'.

WHEN OTHERS.

l_value = 'Scheduled'.

ENDCASE.

l_element_dummy = l_document->create_simple_element(

name = 'type'

value = l_value

parent = l_element_flight ).

ENDLOOP.

IF sy-subrc NE 0.

MESSAGE 'No data into db table ''spfli'', please run program ''SAPBC_DATA_GENERATOR'' with transaction ''SA38''' TYPE 'E'.

ENDIF.

  • Creating a stream factory

l_streamfactory = l_ixml->create_stream_factory( ).

  • Connect internal XML table to stream factory

l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).

  • Rendering the document

l_renderer = l_ixml->create_renderer( ostream = l_ostream

document = l_document ).

l_rc = l_renderer->render( ).

  • Saving the XML document

l_xml_size = l_ostream->get_num_written_raw( ).

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

bin_filesize = l_xml_size

filename = 'c:\temp\flights.xml'

filetype = 'BIN'

CHANGING

data_tab = l_xml_table

EXCEPTIONS

OTHERS = 24.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

<?xml version="1.0"?>

<flights>

<airline code="AA" name="American Airlines">

<flight number="0017">

<from airport="JFK">NEW YORK,US</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>110000</departure>

<arrival>140100</arrival>

<type>Scheduled</type>

</flight>

<flight number="0064">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="JFK">NEW YORK,US</to>

<departure>090000</departure>

<arrival>172100</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="AZ" name="Alitalia">

<flight number="0555">

<from airport="FCO">ROME,IT</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>190000</departure>

<arrival>210500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0788">

<from airport="FCO">ROME,IT</from>

<to airport="TYO">TOKYO,JP</to>

<departure>120000</departure>

<arrival>085500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0789">

<from airport="TYO">TOKYO,JP</from>

<to airport="FCO">ROME,IT</to>

<departure>114500</departure>

<arrival>192500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0790">

<from airport="FCO">ROME,IT</from>

<to airport="KIX">OSAKA,JP</to>

<departure>103500</departure>

<arrival>081000</arrival>

<type>Charter</type>

</flight>

</airline>

<airline code="DL" name="Delta Airlines">

<flight number="1984">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="JFK">NEW YORK,US</to>

<departure>100000</departure>

<arrival>182500</arrival>

<type>Scheduled</type>

</flight>

<flight number="1699">

<from airport="JFK">NEW YORK,US</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>171500</departure>

<arrival>203700</arrival>

<type>Scheduled</type>

</flight>

<flight number="0106">

<from airport="JFK">NEW YORK,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>193500</departure>

<arrival>093000</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="JL" name="Japan Airlines">

<flight number="0407">

<from airport="NRT">TOKYO,JP</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>133000</departure>

<arrival>173500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0408">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="NRT">TOKYO,JP</to>

<departure>202500</departure>

<arrival>154000</arrival>

<type>Charter</type>

</flight>

</airline>

<airline code="LH" name="Lufthansa">

<flight number="2407">

<from airport="TXL">BERLIN,DE</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>071000</departure>

<arrival>081500</arrival>

<type>Scheduled</type>

</flight>

<flight number="2402">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="SXF">BERLIN,DE</to>

<departure>103000</departure>

<arrival>113500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0402">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="JFK">NEW YORK,US</to>

<departure>133000</departure>

<arrival>150500</arrival>

<type>Charter</type>

</flight>

<flight number="0401">

<from airport="JFK">NEW YORK,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>183000</departure>

<arrival>074500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0400">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="JFK">NEW YORK,US</to>

<departure>101000</departure>

<arrival>113400</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="QF" name="Qantas Airways">

<flight number="0005">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>225000</departure>

<arrival>053500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0006">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="SIN">SINGAPORE,SG</to>

<departure>205500</departure>

<arrival>150500</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="SQ" name="Singapore Airlines">

<flight number="0988">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="TYO">TOKYO,JP</to>

<departure>163500</departure>

<arrival>001500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0158">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="JKT">JAKARTA,ID</to>

<departure>152500</departure>

<arrival>160000</arrival>

<type>Scheduled</type>

</flight>

<flight number="0015">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="SIN">SINGAPORE,SG</to>

<departure>160000</departure>

<arrival>024500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0002">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>170000</departure>

<arrival>192500</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="UA" name="United Airlines">

<flight number="0941">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>143000</departure>

<arrival>170600</arrival>

<type>Scheduled</type>

</flight>

<flight number="3504">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>150000</departure>

<arrival>103000</arrival>

<type>Scheduled</type>

</flight>

<flight number="3516">

<from airport="JFK">NEW YORK,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>162000</departure>

<arrival>054500</arrival>

<type>Scheduled</type>

</flight>

<flight number="3517">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="JFK">NEW YORK,US</to>

<departure>104000</departure>

<arrival>125500</arrival>

<type>Scheduled</type>

</flight>

</airline>

</flights>

Regards,

Amit

Reward all helpful replies.

3 REPLIES 3
Read only

amit_khare
Active Contributor
0 Likes
696

Refer the program -

In this implementation we will only focus on the creation of the XML file and the transfer to the user. You can not create a XML document directly. You have to use a so called ixml factory first.

TYPE-POOLS: ixml.

DATA: l_ixml TYPE REF TO if_ixml.

l_ixml = cl_ixml=>create( ).

This iXML factory can create an empty XML document object named l_document.

DATA: l_document TYPE REF TO if_ixml_document.

l_document = l_ixml->create_document( ).

At this point you can add the nodes (elements, attributes) into the document. First you have to declare the root element node.

DATA: l_element_root TYPE REF TO if_ixml_element.

This node we have to give a name and add it (create_simple_node) to the document object l_document, which will be the parent of this node.

l_element_root = l_document->create_simple_element(

name = 'flights'

parent = l_document ).

Next we can add child nodes to there parent node using the same method of the document object.

DATA: l_element_airline TYPE REF TO if_ixml_element,

l_element_airline = l_document->create_simple_element(

name = 'airline'

parent = l_element_root ).

An attribute can be add easily using the method set_attribute of the element node.

l_rc = l_element_airline->set_attribute( name = 'code' value = 'LH401' ).

Now we have finished the document object. Regretfully it can not be displayed in any form due to the fact that it is a binary object.

The next step is to convert the created document to a flat file. To achieve this we have to create a stream factory, which will help us to create an output stream.

DATA: l_streamfactory TYPE REF TO if_ixml_stream_factory.

l_streamfactory = l_ixml->create_stream_factory( ).

In this case, we will convert the document into an output stream which is based on an internal table of type x.

TYPES: BEGIN OF xml_line,

data(256) TYPE x,

END OF xml_line.

DATA: l_xml_table TYPE TABLE OF xml_line,

l_xml_size TYPE i,

l_rc TYPE i,

l_ostream TYPE REF TO if_ixml_ostream.

l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).

When we have created the output stream we can do the rendering from the document into the stream. The XML data will be stored in the internal table automatically.

DATA: l_renderer TYPE REF TO if_ixml_renderer.

l_renderer = l_ixml->create_renderer( ostream = l_ostream

& nbsp; document = l_document ).

l_rc = l_renderer->render( ).

In the last step we upload the file to the sapgui

l_xml_size = l_ostream->get_num_written_raw( ).

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

bin_filesize = l_xml_size

filename = 'c:\temp\flights.xml'

filetype = 'BIN'

CHANGING

data_tab = l_xml_table

EXCEPTIONS

OTHERS = 24.

This finished the first step-of-three. As mentioned before the next log will focus on the conversion from xml files (back) to abap tables.

REPORT z_xit_xml_dom_create.

TYPE-POOLS: ixml.

TYPES: BEGIN OF xml_line,

data(256) TYPE x,

END OF xml_line.

DATA: l_ixml TYPE REF TO if_ixml,

l_streamfactory TYPE REF TO if_ixml_stream_factory,

l_ostream TYPE REF TO if_ixml_ostream,

l_renderer TYPE REF TO if_ixml_renderer,

l_document TYPE REF TO if_ixml_document.

DATA: l_element_flights TYPE REF TO if_ixml_element,

l_element_airline TYPE REF TO if_ixml_element,

l_element_flight TYPE REF TO if_ixml_element,

l_element_from TYPE REF TO if_ixml_element,

l_element_to TYPE REF TO if_ixml_element,

l_element_dummy TYPE REF TO if_ixml_element,

l_value TYPE string.

DATA: l_xml_table TYPE TABLE OF xml_line,

l_xml_size TYPE i,

l_rc TYPE i.

DATA: lt_spfli TYPE TABLE OF spfli.

DATA: l_spfli TYPE spfli.

START-OF-SELECTION.

  • Fill the internal table

SELECT * FROM spfli INTO TABLE lt_spfli.

  • Sort internal table

SORT lt_spfli BY carrid.

  • Start filling xml dom object from internal table

LOOP AT lt_spfli INTO l_spfli.

AT FIRST.

  • Creating a ixml factory

l_ixml = cl_ixml=>create( ).

  • Creating the dom object model

l_document = l_ixml->create_document( ).

  • Fill root node with value flights

l_element_flights = l_document->create_simple_element(

name = 'flights'

parent = l_document ).

ENDAT.

AT NEW carrid.

  • Create element 'airline' as child of 'flights'

l_element_airline = l_document->create_simple_element(

name = 'airline'

parent = l_element_flights ).

  • Create attribute 'code' of node 'airline'

l_value = l_spfli-carrid.

l_rc = l_element_airline->set_attribute( name = 'code' value = l_value ).

  • Create attribute 'name' of node 'airline'

SELECT SINGLE carrname FROM scarr INTO l_value WHERE carrid EQ l_spfli-carrid.

l_rc = l_element_airline->set_attribute( name = 'name' value = l_value ).

ENDAT.

AT NEW connid.

  • Create element 'flight' as child of 'airline'

l_element_flight = l_document->create_simple_element(

name = 'flight'

parent = l_element_airline ).

  • Create attribute 'number' of node 'flight'

l_value = l_spfli-connid.

l_rc = l_element_flight->set_attribute( name = 'number' value = l_value ).

ENDAT.

  • Create element 'from' as child of 'flight'

CONCATENATE l_spfli-cityfrom ',' l_spfli-countryfr INTO l_value.

l_element_from = l_document->create_simple_element(

name = 'from'

value = l_value

parent = l_element_flight ).

  • Create attribute 'airport' of node 'from'

l_value = l_spfli-airpfrom.

l_rc = l_element_from->set_attribute( name = 'airport' value = l_value ).

  • Create element 'to' as child of 'flight'

CONCATENATE l_spfli-cityto ',' l_spfli-countryto INTO l_value.

l_element_to = l_document->create_simple_element(

name = 'to'

value = l_value

parent = l_element_flight ).

  • Create attribute 'airport' of node 'from'

l_value = l_spfli-airpto.

l_rc = l_element_to->set_attribute( name = 'airport' value = l_value ).

  • Create element 'departure' as child of 'flight'

l_value = l_spfli-deptime.

l_element_dummy = l_document->create_simple_element(

name = 'departure'

value = l_value

parent = l_element_flight ).

  • Create element 'arrival' as child of 'flight'

l_value = l_spfli-arrtime.

l_element_dummy = l_document->create_simple_element(

name = 'arrival'

value = l_value

parent = l_element_flight ).

  • Create element 'type' as child of 'flight'

CASE l_spfli-fltype.

WHEN 'X'.

l_value = 'Charter'.

WHEN OTHERS.

l_value = 'Scheduled'.

ENDCASE.

l_element_dummy = l_document->create_simple_element(

name = 'type'

value = l_value

parent = l_element_flight ).

ENDLOOP.

IF sy-subrc NE 0.

MESSAGE 'No data into db table ''spfli'', please run program ''SAPBC_DATA_GENERATOR'' with transaction ''SA38''' TYPE 'E'.

ENDIF.

  • Creating a stream factory

l_streamfactory = l_ixml->create_stream_factory( ).

  • Connect internal XML table to stream factory

l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).

  • Rendering the document

l_renderer = l_ixml->create_renderer( ostream = l_ostream

document = l_document ).

l_rc = l_renderer->render( ).

  • Saving the XML document

l_xml_size = l_ostream->get_num_written_raw( ).

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

bin_filesize = l_xml_size

filename = 'c:\temp\flights.xml'

filetype = 'BIN'

CHANGING

data_tab = l_xml_table

EXCEPTIONS

OTHERS = 24.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

<?xml version="1.0"?>

<flights>

<airline code="AA" name="American Airlines">

<flight number="0017">

<from airport="JFK">NEW YORK,US</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>110000</departure>

<arrival>140100</arrival>

<type>Scheduled</type>

</flight>

<flight number="0064">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="JFK">NEW YORK,US</to>

<departure>090000</departure>

<arrival>172100</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="AZ" name="Alitalia">

<flight number="0555">

<from airport="FCO">ROME,IT</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>190000</departure>

<arrival>210500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0788">

<from airport="FCO">ROME,IT</from>

<to airport="TYO">TOKYO,JP</to>

<departure>120000</departure>

<arrival>085500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0789">

<from airport="TYO">TOKYO,JP</from>

<to airport="FCO">ROME,IT</to>

<departure>114500</departure>

<arrival>192500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0790">

<from airport="FCO">ROME,IT</from>

<to airport="KIX">OSAKA,JP</to>

<departure>103500</departure>

<arrival>081000</arrival>

<type>Charter</type>

</flight>

</airline>

<airline code="DL" name="Delta Airlines">

<flight number="1984">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="JFK">NEW YORK,US</to>

<departure>100000</departure>

<arrival>182500</arrival>

<type>Scheduled</type>

</flight>

<flight number="1699">

<from airport="JFK">NEW YORK,US</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>171500</departure>

<arrival>203700</arrival>

<type>Scheduled</type>

</flight>

<flight number="0106">

<from airport="JFK">NEW YORK,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>193500</departure>

<arrival>093000</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="JL" name="Japan Airlines">

<flight number="0407">

<from airport="NRT">TOKYO,JP</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>133000</departure>

<arrival>173500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0408">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="NRT">TOKYO,JP</to>

<departure>202500</departure>

<arrival>154000</arrival>

<type>Charter</type>

</flight>

</airline>

<airline code="LH" name="Lufthansa">

<flight number="2407">

<from airport="TXL">BERLIN,DE</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>071000</departure>

<arrival>081500</arrival>

<type>Scheduled</type>

</flight>

<flight number="2402">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="SXF">BERLIN,DE</to>

<departure>103000</departure>

<arrival>113500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0402">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="JFK">NEW YORK,US</to>

<departure>133000</departure>

<arrival>150500</arrival>

<type>Charter</type>

</flight>

<flight number="0401">

<from airport="JFK">NEW YORK,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>183000</departure>

<arrival>074500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0400">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="JFK">NEW YORK,US</to>

<departure>101000</departure>

<arrival>113400</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="QF" name="Qantas Airways">

<flight number="0005">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>225000</departure>

<arrival>053500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0006">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="SIN">SINGAPORE,SG</to>

<departure>205500</departure>

<arrival>150500</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="SQ" name="Singapore Airlines">

<flight number="0988">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="TYO">TOKYO,JP</to>

<departure>163500</departure>

<arrival>001500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0158">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="JKT">JAKARTA,ID</to>

<departure>152500</departure>

<arrival>160000</arrival>

<type>Scheduled</type>

</flight>

<flight number="0015">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="SIN">SINGAPORE,SG</to>

<departure>160000</departure>

<arrival>024500</arrival>

<type>Scheduled</type>

</flight>

<flight number="0002">

<from airport="SIN">SINGAPORE,SG</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>170000</departure>

<arrival>192500</arrival>

<type>Scheduled</type>

</flight>

</airline>

<airline code="UA" name="United Airlines">

<flight number="0941">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="SFO">SAN FRANCISCO,US</to>

<departure>143000</departure>

<arrival>170600</arrival>

<type>Scheduled</type>

</flight>

<flight number="3504">

<from airport="SFO">SAN FRANCISCO,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>150000</departure>

<arrival>103000</arrival>

<type>Scheduled</type>

</flight>

<flight number="3516">

<from airport="JFK">NEW YORK,US</from>

<to airport="FRA">FRANKFURT,DE</to>

<departure>162000</departure>

<arrival>054500</arrival>

<type>Scheduled</type>

</flight>

<flight number="3517">

<from airport="FRA">FRANKFURT,DE</from>

<to airport="JFK">NEW YORK,US</to>

<departure>104000</departure>

<arrival>125500</arrival>

<type>Scheduled</type>

</flight>

</airline>

</flights>

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
695

This link addresses ur problem correctly..

regards,

aparna

Read only

Former Member
0 Likes
695

HI,

this program help you to convert into xml and store into system drive into xml format

TYPE-POOLS: ixml.

TYPES: BEGIN OF my_xml,
data1(256) TYPE x,
END OF my_xml.

DATA: itab LIKE catsdb OCCURS 0 WITH HEADER LINE.


DATA: loc TYPE string.
DATA: filename LIKE sy-datum.
DATA: fcreate TYPE string.

filename = sy-datum.
loc = 'd:xml'. "create one folder


CONCATENATE loc filename INTO fcreate.
CONCATENATE fcreate '.xml' INTO fcreate.


DATA: xml_table TYPE TABLE OF my_xml,
l_xml_size TYPE i,
l_xml_rc TYPE i.


SELECT counter pernr workdate beguz enduz catsamount FROM catsdb INTO CORRESPONDING FIELDS OF TABLE itab.

CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
* EXPORTING
*   I_FIELD_SEPERATOR          =
*   I_LINE_HEADER              =
*   I_FILENAME                 =
*   I_APPL_KEEP                = ' '
*   I_XML_DOC_NAME             =
 IMPORTING
   PE_BIN_FILESIZE            = l_xml_size
  TABLES
    i_tab_sap_data             = itab

   CHANGING
   i_tab_converted_data       = xml_table
 EXCEPTIONS
   conversion_failed          = 1
   OTHERS                     = 24
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.




CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
   bin_filesize                  = l_xml_size
    filename                      = fcreate
   filetype                      = 'BIN'
*   APPEND                        = ' '
*   WRITE_FIELD_SEPARATOR         = ' '
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
*   COL_SELECT                    = ' '
*   COL_SELECT_MASK               = ' '
*   DAT_MODE                      = ' '
 IMPORTING
   FILELENGTH                    = l_xml_size
  TABLES
    data_tab                      = xml_table
* EXCEPTIONS
*   FILE_WRITE_ERROR              = 1
*   NO_BATCH                      = 2
*   GUI_REFUSE_FILETRANSFER       = 3
*   INVALID_TYPE                  = 4
*   NO_AUTHORITY                  = 5
*   UNKNOWN_ERROR                 = 6
*   HEADER_NOT_ALLOWED            = 7
*   SEPARATOR_NOT_ALLOWED         = 8
*   FILESIZE_NOT_ALLOWED          = 9
*   HEADER_TOO_LONG               = 10
*   DP_ERROR_CREATE               = 11
*   DP_ERROR_SEND                 = 12
*   DP_ERROR_WRITE                = 13
*   UNKNOWN_DP_ERROR              = 14
*   ACCESS_DENIED                 = 15
*   DP_OUT_OF_MEMORY              = 16
*   DISK_FULL                     = 17
*   DP_TIMEOUT                    = 18
*   FILE_NOT_FOUND                = 19
*   DATAPROVIDER_EXCEPTION        = 20
*   CONTROL_FLUSH_ERROR           = 21
*   OTHERS                        = 22
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


WRITE:  'file created successfully'.

reward points if helpful

thank you,

regards,

Jagrut BharatKumar Shukla