Welcome To My BLOG

This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me

Share this link with your friends

http://www.rebtel.com/u/15163104576

For every friend who signs up using this link and makes a payment, we'll give you 8 €!


Wednesday, September 22, 2010

download to XML

*&---------------------------------------------------------------------*
*& 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

No comments: