2012 Jun 04 10:11 AM
Hi ABAP gurus,
When we use the FM : 'F4_FILENAME' with the parameter PARAMETERS p_path TYPE LOCALFILE. we get the OPEN FILE DIALOG with a button called OPEN which opens the file that we choose to open.
Can anybody tell me how to get the SAVE FILE DIALOG plz? with a button called SAVE which saves the file into the directory that we choose in the dialog.
ABAPly,
Achraf
2012 Jun 04 10:14 AM
hi,
you can use the static method 'FILE_SAVE_DIALOG' of class 'CL_GUI_FRONTEND_SERVICES'.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
* EXPORTING
* window_title =
* default_extension =
* default_file_name =
* with_encoding =
* file_filter =
* initial_directory =
* prompt_on_overwrite = 'X'
CHANGING
filename =
path =
fullpath =
* user_action =
* file_encoding =
* EXCEPTIONS
* cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope this helps. Thank you.
Regards,
kartik
Hi ABAP gurus,
When we use the FM : 'F4_FILENAME' with the parameter PARAMETERS p_path TYPE LOCALFILE. we get the OPEN FILE DIALOG with a button called OPEN which opens the file that we choose to open.
Can anybody tell me how to get the SAVE FILE DIALOG plz? with a button called SAVE which saves the file into the directory that we choose in the dialog.
ABAPly,
Achraf
2012 Jun 04 10:14 AM
hi,
you can use the static method 'FILE_SAVE_DIALOG' of class 'CL_GUI_FRONTEND_SERVICES'.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
* EXPORTING
* window_title =
* default_extension =
* default_file_name =
* with_encoding =
* file_filter =
* initial_directory =
* prompt_on_overwrite = 'X'
CHANGING
filename =
path =
fullpath =
* user_action =
* file_encoding =
* EXCEPTIONS
* cntl_error = 1
* error_no_gui = 2
* not_supported_by_gui = 3
* others = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope this helps. Thank you.
Regards,
kartik
2012 Jun 04 10:17 AM
Use
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'extension'
default_file_name = 'file name'
initial_directory = 'Directory'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
2012 Jun 04 10:19 AM
Hi again,
I find the solution I could delete the post but I think that someone else has the same problem, so let's share the solution :
*Selecting a file to save too, plus inserting default file extension .csv
tables rlgrap.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.
selection-screen begin of block m with frame.
PARAMETERS: p_file TYPE rlgrap-filename.
selection-screen end of block m.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'CSV'
default_file_name = 'accountsdata'
initial_directory = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.
2012 Jun 04 10:21 AM
Hi Achraf
As Kartik mentioned use the
cl_gui_frontend_services=>file_save_dialog method in your "On Value request" for p_path.
This will give you the correct button wording.
Regards
Vic