‎2008 Aug 06 7:41 PM
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!
‎2008 Aug 06 9:23 PM
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
‎2008 Aug 06 7:55 PM
‎2008 Aug 06 8:32 PM
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!
‎2008 Aug 06 8:35 PM
A different approach:
https://forums.sdn.sap.com/click.jspa?searchID=14919169&messageID=2833592
‎2008 Aug 06 9:23 PM
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