Skip to Content
0
Feb 02, 2010 at 04:44 AM

Filter in the Dialog box for selection

23 Views

I have report that contains a file selection dialog using the following code

at selection-screen on value-request for p_file.
  perform f_get_file using cl_gui_frontend_services=>filetype_excel.
form f_get_file using p_filetype type string.
  data: lt_filetable  type filetable,
        ls_file       type line of filetable,
        lv_filename   type string,
        lv_path       type string,
        lv_fullname   type string,
        lv_title      type string,
        lv_desktop    type string,
        lv_rc         type i,
        lv_action     type i.
  call method cl_gui_frontend_services=>get_desktop_directory
    changing
      desktop_directory    = lv_desktop
    exceptions
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      others               = 4.
  if sy-subrc <> 0.
    message e007(zspx) with 'Desktop not found'.
  endif.

* Update View
  call method cl_gui_cfw=>update_view
    exceptions
      cntl_system_error = 1
      cntl_error        = 2
      others            = 3.

  lv_title = text-003.
  call method cl_gui_frontend_services=>file_open_dialog
    exporting
      window_title            = lv_title
      file_filter             = p_filetype
      initial_directory       = lv_desktop
    changing
      file_table              = lt_filetable
      rc                      = lv_rc
      user_action             = lv_action
    exceptions
      file_open_dialog_failed = 1
      cntl_error              = 2
      error_no_gui            = 3
      others                  = 4.
  if sy-subrc = 0 and lv_action ne cl_gui_frontend_services=>action_cancel.
    read table lt_filetable into ls_file index 1.
    if sy-subrc = 0.
      p_file = ls_file-filename.
    else.
      clear p_file.
    endif.
  else.
    clear p_file.
  endif.
endform.                    " f_get_file

Currently while opening the dialog for file selection its showing the desktop directory. But user can select file from any other directory.

My question is how to restrict this dialog box from which user can select only from desktop directory.

PS : Please don't suggest to validate the file after getting the file that its from desktop or not