ABAP To XML
ABAP To XML
**********************************************************************
* REPORT Z_DOWN_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 *
*--------------------------------------------------------------------*
* Author : Michel PIOUD *
* Email : [email protected] HomePage : http://www.geocities.com/mpioud *
**********************************************************************
* Databases
TABLES:
makt, "Mat description
marc, "Material / plant
t001w, "plant name
bhdgd. "Batch heading
* Internal tables
DATA:
BEGIN OF gt_marc OCCURS 0,
werks LIKE marc-werks,
matnr LIKE marc-matnr,
END OF gt_marc,
* Table to be downloaded as xml. Each line stores start and end tags
* and the value
BEGIN OF gt_xml OCCURS 0,
line(120),
END OF gt_xml,
g_maktx(120).
* User-input
SELECT-OPTIONS:
s_werks FOR marc-werks,
s_matnr FOR marc-matnr.
**********************************************************************
START-OF-SELECTION.
**********************************************************************
END-OF-SELECTION.
LOOP AT gt_marc.
PERFORM read_description.
CLEAR gt_xml.
gt_xml-line = ' <MATERIAL>'.
APPEND gt_xml.
CLEAR gt_xml.
CONCATENATE ' <NAME>' g_maktx '</NAME>'
INTO gt_xml-line.
APPEND gt_xml.
CLEAR gt_xml.
CONCATENATE ' <NUMBER>' gt_marc-matnr '</NUMBER>'
INTO gt_xml-line.
APPEND gt_xml.
CLEAR gt_xml.
gt_xml-line = ' </MATERIAL>'.
APPEND gt_xml.
CLEAR gt_xml.
* display data
FORMAT COLOR 2 ON.
WRITE :/ gt_marc-matnr, makt-maktx.
FORMAT COLOR 2 OFF.
ENDLOOP.
**********************************************************************
TOP-OF-PAGE.
*---------------------------------------------------------------------*
* Form READ_PLANT
*---------------------------------------------------------------------*
FORM read_plant.
* Material name
CLEAR g_maktx.
SELECT SINGLE maktx
INTO g_maktx
FROM makt
WHERE matnr EQ gt_marc-matnr
AND spras EQ 'E'.