PARAMETERS: p_idoc TYPE edi_docnum.
START-OF-SELECTION.
TRY.
DATA(o_idoc_xml) = NEW cl_idoc_xml1( docnum = p_idoc ).
DATA: lv_xml TYPE string.
o_idoc_xml->get_xmldata_as_string( IMPORTING data_string = lv_xml ).
DATA(it_xml) = VALUE stringtab( ( |{ lv_xml }| ) ).
DATA: lv_temp_dir TYPE string.
* Temp-Directory holen
cl_gui_frontend_services=>get_desktop_directory( CHANGING desktop_directory = lv_temp_dir ).
* Note 1442303, sonst ist lv_temp_dir leer
cl_gui_cfw=>flush( ).
* Dateinamen zusammenbauen
DATA(lv_filename) = |{ lv_temp_dir }\\my_xml.xml|.
* Datei im Zielverzeichnis erzeugen
cl_gui_frontend_services=>gui_download( EXPORTING
filename = lv_filename
filetype = 'ASC'
CHANGING
data_tab = it_xml ).
WRITE: / lv_filename.
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.