Here I have used CL_GUI_FRONTEND_SERVICES class to copy TXT file content.
In below program demo.txt file must exist in your desktop with some content in it.
Code :
DATA: obj TYPE REF TO cl_gui_frontend_services.
DATA: lv_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = 'C:\Users\CODETHETA\Desktop\demo.txt'
CHANGING
rc = lv_rc
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8
OTHERS = 9.
IF sy-subrc <> 0.
WRITE: 'File Not Deleted'.
ELSE.
WRITE: 'File Deleted'.
ENDIF.
DATA: lv_rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = 'C:\Users\CODETHETA\Desktop\demo.txt'
CHANGING
rc = lv_rc
EXCEPTIONS
file_delete_failed = 1
cntl_error = 2
error_no_gui = 3
file_not_found = 4
access_denied = 5
unknown_error = 6
not_supported_by_gui = 7
wrong_parameter = 8
OTHERS = 9.
IF sy-subrc <> 0.
WRITE: 'File Not Deleted'.
ELSE.
WRITE: 'File Deleted'.
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