Application Development 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: 

cl_gui_frontend_services dialog

Former Member
0 Kudos

Hello gurus,

I'm trying to use CL_GUI_FRONTEND_SERVICES to give users a popup file selector box and select one file.

That file will be used later in the program for either uploading or downloading data.

I can't seem to find a method that does what I want.

Have you any suggestions?

Thanks

Ed Baker

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

Use method FILE_OPEN_DIALOG of the CL_GUI_FRONTEND_SERVICES.

Like:


  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    EXPORTING
      WINDOW_TITLE            = 'Select a file'
      DEFAULT_FILENAME        = L_TYPE
    CHANGING
      FILE_TABLE              = LT_FILES
      RC                      = RC
    EXCEPTIONS
      FILE_OPEN_DIALOG_FAILED = 1
      CNTL_ERROR              = 2
      ERROR_NO_GUI            = 3
      OTHERS                  = 4.
  IF SY-SUBRC <> 0.
    MESSAGE E398(00) WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Get file selected
  READ TABLE LT_FILES INDEX 1 INTO LW_FILES.
  MOVE LW_FILES-FILENAME TO P_LFILE.

Regards,

Naimesh Patel

5 REPLIES 5

naimesh_patel
Active Contributor
0 Kudos

Use method FILE_OPEN_DIALOG of the CL_GUI_FRONTEND_SERVICES.

Like:


  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    EXPORTING
      WINDOW_TITLE            = 'Select a file'
      DEFAULT_FILENAME        = L_TYPE
    CHANGING
      FILE_TABLE              = LT_FILES
      RC                      = RC
    EXCEPTIONS
      FILE_OPEN_DIALOG_FAILED = 1
      CNTL_ERROR              = 2
      ERROR_NO_GUI            = 3
      OTHERS                  = 4.
  IF SY-SUBRC <> 0.
    MESSAGE E398(00) WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Get file selected
  READ TABLE LT_FILES INDEX 1 INTO LW_FILES.
  MOVE LW_FILES-FILENAME TO P_LFILE.

Regards,

Naimesh Patel

0 Kudos

Hi. Thanks for replying.

I should have mentioned what I'd done so far.

My biggest problem is that the method doesn't seem to pay any attention to the default directory.

The default directory is always whatever the user last used when he left Windows Explorer.

That seems odd to me.


  CONCATENATE 'C:\Documents and Settings\edward.baker\'
  'My Documents\Thermo_Upgrade_Project\vbis_replacement\'
  INTO default_directory.

  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title            = 'File Dialog'
      default_extension       = '*.xml'
*    default_filename        =
      file_filter             = '*.xml'
*    with_encoding           =
      initial_directory       = default_directory
*    multiselection          =
    CHANGING
      file_table              = lt_filetable
      rc                      = lv_rc
*    user_action             =
*    file_encoding           =

0 Kudos

You can use the DIRECTORY_SET_CURRENT. In the description, it says don't use but it is working.

Call this method before the FILE_OPEN_DIALOG


data: l_rc type sy-subrc.
CALL METHOD cl_gui_frontend_services=>directory_set_current
  EXPORTING
    current_directory            = 'C:\temp'
  changing
    rc                           = l_rc.

Regards,

Naimesh Patel.

0 Kudos

Perfect.

I didn't notice that method before.

Thank You

former_member188685
Active Contributor
0 Kudos

Check the FILE_OPEN_DIALOG/FILE_SAVE_DIALOG method.