02-02-2010 4:44 AM
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
a®
02-02-2010 6:53 AM
Hi,
Can we do like this?
As you said...After selection of the file.....
if the file is from other location...we can display a information message and ask him to select again by calling the same routine until he selects from the desktop.
Thanks & Regards,
Vamsi.
02-02-2010 6:53 AM
Hi,
Can we do like this?
As you said...After selection of the file.....
if the file is from other location...we can display a information message and ask him to select again by calling the same routine until he selects from the desktop.
Thanks & Regards,
Vamsi.
02-02-2010 6:56 AM
Hi,
Like the bellow ?
Replace following code
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.
with the bellow
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.
FIND FIRST OCCURRENCE OF lv_desktop IN ls_file-filename.
IF sy-subrc = 0.
p_file = ls_file-filename.
ELSE.
MESSAGE: 'Sorry! you can select file only from Desktop' TYPE 'I'.
PERFORM f_get_file USING cl_gui_frontend_services=>filetype_excel.
ENDIF.
ELSE.
CLEAR p_file.
ENDIF.
ELSE.
CLEAR p_file.
ENDIF.
Regards,
Faisal
02-02-2010 8:18 AM
Faisal,
I find controlling dialog box is not possible . Your option is alternative solution to this
a®