Variante 1 (cl_gui_frontend_services)
PARAMETERS: p_fname TYPE file_table-filename OBLIGATORY DEFAULT 'c:\test.xlsx'.
* wenn die F4-Hilfe für den Dateinamen aufgerufen wird
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
DATA: lv_action TYPE i.
DATA: lv_filename TYPE string.
DATA: lv_fullpath TYPE string.
DATA: lv_path TYPE string.
* FileSave-Dialog aufrufen
TRY.
cl_gui_frontend_services=>file_save_dialog( EXPORTING
default_extension = 'xlsx' " default Dateinnamenerweiterung
default_file_name = |{ p_fname }| " default Dateiname
file_filter = |xlsx (*.xlsx)\|*.xlsx\|{ cl_gui_frontend_services=>filetype_all }|
prompt_on_overwrite = abap_true
CHANGING
filename = lv_filename " Dateiname
path = lv_path " Pfad
fullpath = lv_fullpath " Pfad + Dateiname
user_action = lv_action ). " Benutzeraktion
IF lv_action EQ cl_gui_frontend_services=>action_ok.
p_fname = lv_fullpath.
ENDIF.
CATCH cx_root INTO DATA(e_text). " Oberklasse für Exceptions abfangen und Kurztext übergeben
MESSAGE e_text->get_text( ) TYPE 'I'. " Exception Kurztext ausgeben
ENDTRY.
Variante 2 (cl_openxml_helper)
DATA(lv_default_filename) = |Excelfile.xlsx|.
DATA(lv_filterpattern) = |Excel-Datei (*.xlsx)\|*.xlsx\|{ cl_gui_frontend_services=>filetype_all }|.
DATA(lv_savefile) = cl_openxml_helper=>browse_local_file_save( iv_title = 'Datei speichern'
iv_filename = lv_default_filename
iv_extpattern = lv_filterpattern ).
WRITE: / lv_savefile.