I have written this code , :
1) to let the user select the directiry he wants the files for . ( he may want to use a variant or the directory browse )
2) Let the user select the file ( file_open_dialog )
at selection-screen on value-request for path_str.
But , After the FILE OPEN DIALOG FM , when the user finally selects the file 'c:\jshdjs\mn.txt' , the filename doesnt appear in the screen field <b>path_str</b>..it just stays blank in contrast to what happens using F4_filename ( where the selected file name is filled on the screen field )
at selection-screen on value-request for <b>path_str</b>.
call method cl_gui_frontend_services=>directory_browse
exporting
window_title = 'Select Directory'
changing
selected_folder = path_str1
exceptions
cntl_error = 1.
call method cl_gui_cfw=>flush
exceptions
cntl_system_error = 1
cntl_error = 2.
p_path = path_str.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
DEFAULT_FILENAME = 'C:\'
INITIAL_DIRECTORY = path_str1
CHANGING
FILE_TABLE = ITAB_FILE1_TABLE
RC = RC_FILE
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH* SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.
Thanks
Please see the modified code.
report zrich_0001 . data: path_str1 type string. data: rc_file type i. data: itab_file1_table type table of file_table. data: wa_file1 like line of itab_file1_table. <b>parameters: p_file type localfile.</b> at selection-screen on value-request for <b>p_file</b>. call method cl_gui_frontend_services=>directory_browse exporting window_title = 'Select Directory' changing selected_folder = path_str1 exceptions cntl_error = 1. call method cl_gui_cfw=>flush exceptions cntl_system_error = 1 cntl_error = 2. call method cl_gui_frontend_services=>file_open_dialog exporting * DEFAULT_FILENAME = 'C:' initial_directory = path_str1 changing file_table = itab_file1_table rc = rc_file exceptions file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 * not_supported_by_gui = 4 others = 5. <b> read table itab_file1_table into wa_file1 index 1. if sy-subrc = 0. p_file = wa_file1-filename. endif.</b>
Regards,
Rich Heilman
Add a comment