Variante 1 (cl_gui_frontend_services)
TRY.
* beliebiger Stream
DATA: lv_xdata TYPE xstring.
...
* xstring -> solix
DATA(it_solix_data) = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xdata ).
* Daten lokal speichern
cl_gui_frontend_services=>gui_download( EXPORTING
filename = |Bild.png|
filetype = 'BIN'
bin_filesize = xstrlen( lv_xdata )
CHANGING
data_tab = it_solix_data ).
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.
Variante 2 (cl_gui_frontend_services)
* Inhalt einer internen Tabelle als Datei (CSV) auf den lokalen Rechner speichern:
* http://help.sap.com/saphelp_nw70ehp2/helpdata/de/c7/5ab8ec178c44a8aacd1dcac3460db8/content.htm
* CSV-Daten
DATA: itab TYPE STANDARD TABLE OF string.
* Dateipfad + Dateiname
DATA: lv_file TYPE string VALUE 'c:\temp\test.txt'.
...
TRY.
cl_gui_frontend_services=>gui_download( EXPORTING
filename = lv_file
filetype = 'DAT' " mögliche Filetypen: BIN, ASC, DAT, DBF, WK1, VSS, IBM
codepage = '4110' " UTF-8 Encoding: 4110, UTF-16 Big Endian : 4102, UTF-16 Little Endian : 4103.
CHANGING
data_tab = itab ).
WRITE: / |Datei erfolgreich unter { lv_file } gespeichert.|.
CATCH cx_root INTO DATA(e_text).
MESSAGE e_text->get_text( ) TYPE 'I'.
ENDTRY.
Variante 3 (cl_secxml_helper)
TRY.
* Daten als Stream
DATA: lv_xdata TYPE xstring.
...
* File lokal speichern auf dem Frontend
cl_secxml_helper=>save_file( EXPORTING default_file_name = ''
initial_directory = ''
window_title = 'Datei speichern'
bindata = lv_xdata ).
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.