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

xml format

Former Member
0 Likes
771

Hello all,

I'm stuck at an output file, so I have my program generated the output file, I have everything in internal table itab. But I need to generate the output file in xml format. My question is do you know any function module doing the job? like export import everything from my internal table and create an xml file? Or that's something I have to hardcode in my program?

Any helpful idea will be highly appreciated. Thanks!

1 ACCEPTED SOLUTION
Read only

raja_thangamani
Active Contributor
0 Likes
632

In the Class CL_XML_DOCUMENT, we have a method EXPORT_TO_FILE to download an XML file.

  
DATA:  l_subrc    TYPE sysubrc,
       l_lfile    TYPE localfile,
      l_file     TYPE string,
      l_title    TYPE string,
      l_path     TYPE string,
      l_fullpath TYPE string.

CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      window_title      = l_title
      default_extension = 'XML'
      file_filter       = 'XML'
    CHANGING
      filename          = l_file
      path              = l_path
      fullpath          = l_fullpath
    EXCEPTIONS
      OTHERS            = 1.
  IF sy-subrc = 0.
    l_lfile = l_fullpath.

    CALL METHOD l_xml->export_to_file
      EXPORTING
        filename = l_lfile
      RECEIVING
        retcode  = l_subrc.
  ENDIF.

Raja

4 REPLIES 4
Read only

raja_thangamani
Active Contributor
0 Likes
632

Check out the FM SAP_CONVERT_TO_XML_FORMAT

Below are the useful threads:

[Generate XML|]

[Download XML|]

Raja

Read only

0 Likes
632

Hi Raja, thanks for your quick response, i followed this and it works

DATA : ITAB TYPE TABLE OF SPFLI,

L_XML TYPE REF TO CL_XML_DOCUMENT.

SELECT * FROM SPFLI INTO TABLE ITAB.

  • CREATE THE XML OBJECT

CREATE OBJECT L_XML.

  • CONVERT THE DATA TO XML

CALL METHOD L_XML->CREATE_WITH_DATA( DATAOBJECT = ITAB[] ).

  • DATA IS CONVERTED TO XML; DISPLAY THE XML-DOCUMENT

CALL METHOD L_XML->DISPLAY.

However, It just display the XML output file in SAP, how do I put it in an output internal table?

I think it should be CALL METHOD L_XML->"something here". Thanks!

Read only

Read only

raja_thangamani
Active Contributor
0 Likes
633

In the Class CL_XML_DOCUMENT, we have a method EXPORT_TO_FILE to download an XML file.

  
DATA:  l_subrc    TYPE sysubrc,
       l_lfile    TYPE localfile,
      l_file     TYPE string,
      l_title    TYPE string,
      l_path     TYPE string,
      l_fullpath TYPE string.

CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      window_title      = l_title
      default_extension = 'XML'
      file_filter       = 'XML'
    CHANGING
      filename          = l_file
      path              = l_path
      fullpath          = l_fullpath
    EXCEPTIONS
      OTHERS            = 1.
  IF sy-subrc = 0.
    l_lfile = l_fullpath.

    CALL METHOD l_xml->export_to_file
      EXPORTING
        filename = l_lfile
      RECEIVING
        retcode  = l_subrc.
  ENDIF.

Raja