2007 Oct 30 2:54 PM
Hi All,
I'm currently using FM: FILE_GET_NAME_USING_PATH, and I'd like to do a check to see if the filepath with file (i.e. /com/tmp/file.txt) I am getting back exists or not.
Very simple question, just not sure what to do.
Thanks,
John
2007 Oct 30 2:57 PM
Use OPEN DATASET. The file wil be opened in READ Mode.
If sy-subrc is 0 that means file exists.
Regards,
Aj
Hi All,
I'm currently using FM: FILE_GET_NAME_USING_PATH, and I'd like to do a check to see if the filepath with file (i.e. /com/tmp/file.txt) I am getting back exists or not.
Very simple question, just not sure what to do.
Thanks,
John
2007 Oct 30 2:57 PM
Use OPEN DATASET. The file wil be opened in READ Mode.
If sy-subrc is 0 that means file exists.
Regards,
Aj
2007 Oct 30 2:58 PM
Hi,
You will have to open the file using OPEN DATASET or GUI_UPLOAD. If this fails, it will return sy-subrc 4 which will show that file exists or not.
ashish
2007 Oct 30 2:58 PM
hi John,
try the method DIRECTORY_EXIST of class CL_GUI_FRONTEND_SERVICES.
hope this helps
ec
2007 Oct 30 3:00 PM
2007 Oct 30 2:59 PM
There is a class that provides methods to check, if a file exist or if a certain directory does exist
CALL METHOD cl_gui_frontend_services=>directory_exist
EXPORTING
directory = lv_path
RECEIVING
result = lv_valid
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = x_file_with_path
RECEIVING
result = y_file_exists
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
Hope that helps,
Michael
2007 Oct 30 2:59 PM
2007 Oct 30 3:20 PM
use fm's EPS_GET_FILE_ATTRIBUTES
or EPS_GET_DIRECTORY_LISTING
A.
2013 Jun 19 6:44 AM
Hi,
You may try the following class method
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = File_Path " e.g.'C:\Temp\file.dat'
RECEIVING
result = ret_code. " type i.
2015 Nov 26 9:15 AM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |