Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Save file dialog

achraf_smaali
Explorer
12,759

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

1 ACCEPTED SOLUTION
Read only

Kartik2
Contributor
5,083

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

4 REPLIES 4
Read only

Kartik2
Contributor
5,084

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

Read only

Former Member
0 Likes
5,083

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.




Read only

achraf_smaali
Explorer
5,083

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.

Read only

Former Member
0 Likes
5,083

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