Skip to Content
avatar image
Former Member

send data to xml file

hi,

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    May 20, 2009 at 07:08 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • avatar image
    Former Member
    May 20, 2009 at 07:10 AM

    Hello,

    Try using the FM 'SAP_CONVERT_TO_XML_FORMAT'.

    Regards,

    Sachinkumar Mehta

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

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