Application Development 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: 

convert in xml format

Former Member
0 Kudos

how to download any report in xml. directly thru code.

means if a report is run report should be download in xml format.

any fuction module ???

points will be awarded.

7 REPLIES 7

Former Member
0 Kudos

use Fm GUI_DOWNLOAD

and give the file format as 'XML'

Regards,

kushagra sharma

Former Member
0 Kudos

i assume you have an internal table which you are displaying as a list and the same is required to be converted into xml format.

you can use the CALL TRANSFORMATION statement to do the same.

0 Kudos

no my queastion is i have one report which in heirachal ALV.

its running well and fine.

now it should run in back ground and report should save in XML format.

0 Kudos

no my queastion is i have one report which in heirachal ALV.

its running well and fine.

now it should run in back ground and report should save in XML format automatically

0 Kudos

can you provide any sample program??

Former Member
0 Kudos

Hi check this one ......

&----


*& Report ZTEST_XML2 *

*& *

&----


*& *

*& *

&----


REPORT ZTEST_XML2 .

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'' type 'E'.

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

Regards,

Prasad.

0 Kudos

hello suppoase this the program. KSCHL may be different.

tell me how to download in xml. using call transform/

REPORT ZSD_UTXJ .

tables: a368 , konp.

data: begin of it_utxj occurs 0,

KSCHL like a368-KSCHL,

aland like a368-aland,

wkreg like a368-wkreg,

regio like a368-regio,

TAXK1 like a368-TAXK1,

TAXM1 like a368-TAXM1,

DATBI like a368-DATBI,

DATAB like a368-DATAB,

KNUMH like a368-KNUMH,

MWSK1 like konp-MWSK1,

end of it_utxj.

********************

DATA : mc_filename LIKE rlgrap-filename.

DATA : filename TYPE string.

************************

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: S_DATE FOR A368-DATBI.

SELECTION-SCREEN: END OF BLOCK b1.

start-of-selection.

perform getdata.

IF IT_UTXJ[] IS NOT INITIAL.

perform display1.

    • perform display.

ENDIF.

end-of-selection.

&----


*& Form getdata

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM getdata .

select aKSCHL aaland awkreg aregio aTAXK1 aTAXM1 aDATBI aDATAB aKNUMH bMWSK1

into CORRESPONDING FIELDS OF TABLE it_UTXJ

from a368 as a inner join konp as b on akschl = bkschl

and aknumh = bknumh

*UP TO 1 ROWS

where A~KSCHL = 'UTXJ' and

A~DATAB <= S_DATE-LOW

AND A~DATBI >= S_DATE-low

order by a~datab descending.

ENDFORM.