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: 

send data to xml file

Former Member
0 Kudos

hi,

can you please let me know how to send the data to xml file

5 REPLIES 5

Former Member
0 Kudos

are you talking about the Output data ?

use this code

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

SELECT werks matnr

INTO TABLE gt_marc

FROM marc

up to 20 rows.

SORT gt_marc BY werks matnr.

LOOP AT gt_marc.

AT FIRST. "First tag must be root

CLEAR gt_xml.

gt_xml-line = '<LOCATIONS>'.

APPEND gt_xml.

CLEAR gt_xml.

ENDAT.

AT NEW werks. "At new plant

PERFORM read_plant.

FORMAT COLOR 4 ON.

SKIP 1.

WRITE 😕 gt_marc-werks, t001w-name1.

FORMAT COLOR 4 OFF.

CLEAR gt_xml.

gt_xml-line = ' <PLANT>'.

APPEND gt_xml.

CLEAR gt_xml.

CONCATENATE ' <NUMBER>' gt_marc-werks '</NUMBER>'

INTO gt_xml-line.

APPEND gt_xml.

CLEAR gt_xml.

CONCATENATE ' <NAME>' t001w-name1 '</NAME>' INTO gt_xml-line.

APPEND gt_xml.

CLEAR gt_xml.

gt_xml-line = ' </PLANT>'.

APPEND gt_xml.

CLEAR gt_xml.

ENDAT.

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.

  • The last tag must be the root closing tag --*

gt_xml-line = '</LOCATIONS>'.

APPEND gt_xml.

CLEAR gt_xml.

CALL FUNCTION 'DOWNLOAD'

EXPORTING

filename = 'C:\PLANT1.XML'

filetype = 'ASC'

TABLES

data_tab = gt_xml.

0 Kudos

hi,

i have to save the data in XML format on both application server and presentation server

0 Kudos

hi,

i have to save the data in XML format on both application server and presentation server

Edited by: VIJAY THANDRA on May 20, 2009 9:16 AM

Former Member
0 Kudos

Hello,

Try using the FM 'SAP_CONVERT_TO_XML_FORMAT'.

Regards,

Sachinkumar Mehta

0 Kudos

Hi,

i have to save my internal table data in xml format on both application server and presentation sever