This small piece of code can help to delete any file from windows directory.
REPORT YKC_DELETE_FILE_ON_WIN.data: file type string,
code type i.
PARAMETER P_FILE TYPE RLGRAP-FILENAME .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE '
IMPORTING
FILE_NAME = P_FILE.
file = P_FILE.
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename = file
changing
rc = code
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.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Information'
txt1 = 'Success'
txt2 = 'File Deleted'
txt3 = ' '
txt4 = ' '.
else.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Information'
txt1 = 'Failure'
txt2 = 'Unable to Delete'
txt3 = ' '
txt4 = ' '.
ENDIF.
No comments:
Post a Comment