Code :
REPORT zvp_file_exist.
DATA: lv_file TYPE string.
DATA: lv_result TYPE string.
lv_file = 'C:\Users\CODETHETA\Desktop\demo.txt'.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
IF lv_result = 'X'.
WRITE: 'File Exist'.
ELSE.
WRITE: 'File Not Exist'.
ENDIF.
DATA: lv_file TYPE string.
DATA: lv_result TYPE string.
lv_file = 'C:\Users\CODETHETA\Desktop\demo.txt'.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
IF lv_result = 'X'.
WRITE: 'File Exist'.
ELSE.
WRITE: 'File Not Exist'.
ENDIF.
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.
Post a Comment