Application Development and Automation 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: 
Read only

send data to xml file

Former Member
0 Likes
735

hi,

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

5 REPLIES 5
Read only

Former Member
0 Likes
698

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.

Read only

0 Likes
698

hi,

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

Read only

0 Likes
698

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

Read only

Former Member
0 Likes
698

Hello,

Try using the FM 'SAP_CONVERT_TO_XML_FORMAT'.

Regards,

Sachinkumar Mehta

Read only

0 Likes
698

Hi,

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