‎2006 Oct 27 6:42 PM
Hi,
I'm generating files in my program and dropping those files based on the path given in the selection screen. The user might choose a path on his system or shared drive or a path on the app. server.
I need to validate whether those paths, whether those paths exists or not. please let me know how to handle this situation.
Regards,
ravi.
‎2006 Oct 27 6:52 PM
‎2006 Oct 27 6:52 PM
‎2006 Oct 27 6:56 PM
You can use this example.
report zrich_0001 .
type-pools: abap.
data: path type string.
data: result type abap_bool.
parameters: p_path type localfile default 'C:sap'.
at selection-screen .
path = p_path.
call method cl_gui_frontend_services=>directory_exist
exporting
directory = path
receiving
result = result
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
.
if result = space.
message e001(00) with 'Path/Directory does not exist'.
endif.
Regards,
Rich Heilman
‎2006 Oct 27 6:52 PM
Hi Ravi,
Please check this sample codes.
DATA: c_file_mask TYPE dxfields-filemask VALUE '*',
searched_dir TYPE dxfields-longpath,
file_path LIKE dxfields-longpath.
searched_dir = 'INITIAL_DIRECTORY_TO_START_WITH'.
TRANSLATE searched_dir TO LOWER CASE .
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
i_server = ' '
i_path = searched_dir
filemask = c_file_mask
* FILEOPERATION = 'R'
IMPORTING
* O_LOCATION_FLAG =
* O_SERVER =
o_path = file_path
* ABEND_FLAG =
EXCEPTIONS
rfc_error = 1
OTHERS = 2.
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 will help.
Regards,
Ferry Lianto