*& Report ZDOWNLOAD_TO_XML *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZDOWNLOAD_TO_XML
line-size 132 no standard page heading.
*-Download data in XML format
**********************************************************************
* REPORT ZDOWNLOAD_TO_XML - Using an internal table (gt_marc) *
* and downloading the report data as an xml file *
* The xml indentation is hard coded into the file *
**********************************************************************
* Databases
tables: mara.
* Internal tables
data:
begin of gt_mard occurs 0,
matnr like mard-matnr,
werks like mard-werks,
lgort like mard-lgort,
end of gt_mard.
* Table to be downloaded as xml. Each line stores start and end tags
* and the value
data: begin of gt_xml occurs 0,
line(120),
end of gt_xml.
select-options: s_matnr for mara-matnr.
start-of-selection.
perform main_processing.
**********************************************************************
end-of-selection.
perform write_to_xml.
*---------------------------------------------------------------------*
* Form MAIN_PROCESSING
*---------------------------------------------------------------------*
form main_processing.
* Material and plant basic data
select matnr werks lgort
into table gt_mard
from mard
where matnr in s_matnr.
endform. " MAIN_PROCESSING
*&---------------------------------------------------------------------*
*& Form write_to_xml
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------*
FORM write_to_xml .
sort gt_mard by WERKS.
loop at gt_mard. at first. "First tag must be root clear gt_xml.
gt_xml-line = ''.
append gt_xml.
clear gt_xml.
endat.
at new WERKS. "At new material
clear gt_xml.
gt_xml-line = ''.
append gt_xml.
clear gt_xml.
concatenate '' gt_mard-matnr ' ' into gt_xml-line.
append gt_xml.
clear gt_xml.
concatenate '' gt_mard-werks ' ' into gt_xml-line.
append gt_xml.
clear gt_xml.
concatenate '' gt_mard-lgort ' ' into gt_xml-line.
append gt_xml.
clear gt_xml.
gt_xml-line = ' '.
append gt_xml.
clear gt_xml.
endat.
endloop.
* The last tag must be the root closing tag --*
gt_xml-line = ' '.
append gt_xml.
clear gt_xml.
call function 'DOWNLOAD'
exporting
filename = 'C:\PLANT1.XML'
filetype = 'ASC'
tables
data_tab = gt_xml.
ENDFORM. " write_to_xml
ALSO READ:
- Download SAPScript Output To PDF File.
- Download Data From Application Server Files To Presentation Server Using FM C13Z_APPL_TO_FRONT_END.
- Creating A Directory On Presentation Server Using FM GUI_CREATE_DIRECTORY.
- Removing A Directory From Presentation Server Using FM GUI_REMOVE_DIRECTORY.
- Removing A File From Presentation Server Using FM GUI_DELETE_FILE.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
append gt_xml.
clear gt_xml.
endat.
at new WERKS. "At new material
clear gt_xml.
gt_xml-line = '
append gt_xml.
clear gt_xml.
concatenate '
append gt_xml.
clear gt_xml.
concatenate '
append gt_xml.
clear gt_xml.
concatenate '
append gt_xml.
clear gt_xml.
gt_xml-line = '
append gt_xml.
clear gt_xml.
endat.
endloop.
* The last tag must be the root closing tag --*
gt_xml-line = '
append gt_xml.
clear gt_xml.
call function 'DOWNLOAD'
exporting
filename = 'C:\PLANT1.XML'
filetype = 'ASC'
tables
data_tab = gt_xml.
ENDFORM. " write_to_xml
ALSO READ:
- Download SAPScript Output To PDF File.
- Download Data From Application Server Files To Presentation Server Using FM C13Z_APPL_TO_FRONT_END.
- Creating A Directory On Presentation Server Using FM GUI_CREATE_DIRECTORY.
- Removing A Directory From Presentation Server Using FM GUI_REMOVE_DIRECTORY.
- Removing A File From Presentation Server Using FM GUI_DELETE_FILE.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
No comments:
Post a Comment