Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
Introduction: This small piece of code can help to delete any file from windows directory.

 


Error rendering macro 'code': Invalid value specified for parameter 'lang'
*&---------------------------------------------------------------------*
*& Report YKC_DELETE_FILE_ON_WIN
*&
*&---------------------------------------------------------------------*
*&Krishna Chauhan (Sparta consulting)
*&12 Jan 09
*&This small piece of code will help to delete any file from windows.
*&---------------------------------------------------------------------*
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.


 

 

1 Comment

  1. Guest

    Good work chouhan....