Skip to end of metadata
Go to start of metadata
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT zdelete.
*----------------------------------------------------------------------*
* Delete a file on the application server.
*----------------------------------------------------------------------*
PARAMETERS: p_dir LIKE rlgrap-filename
                  DEFAULT '/usr/sap/trans/',
            p_file1 LIKE rlgrap-filename.

DATA: p_file(128).
DATA: w_ans.

START-OF-SELECTION.
  CONCATENATE p_dir p_file1 INTO p_file.
*----------------------------------------------------------------------*
* check file exists
*----------------------------------------------------------------------*
  OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
  IF sy-subrc NE 0.
    MESSAGE e899(bd) WITH p_file 'DOES NOT EXIST'.
    EXIT.
  ELSE.

    CALL FUNCTION 'POPUP_CONTINUE_YES_NO'
      EXPORTING
        defaultoption = 'N'
        textline1     = p_dir
        textline2     = p_file1
        titel         = 'ARE YOU SURE YOU WANT TO DELETE'
      IMPORTING
        answer        = w_ans
      EXCEPTIONS
        OTHERS        = 1.

  ENDIF.
  CLOSE DATASET p_file.
  CHECK w_ans = 'J'.
*----------------------------------------------------------------------*
* delete
*----------------------------------------------------------------------*

  DELETE DATASET p_file.

  IF sy-subrc NE 0.
    MESSAGE e899(bd) WITH 'INVALID FILE NAME' p_file.
  ELSE.
    CLOSE DATASET p_file.
    MESSAGE i899(bd) WITH p_dir p_file1 'DELETED SUCCESFULLY'.
  ENDIF.


Output:-

*Enter the Directory name & File Name *







*Press F8*

*Press Enter*

 
*Go to Transcation AL11 ->Double Click on DIR_TEMP-> You can find the List of file*

*Before Deleting the File*

 
 *After Deleting the File*

  

When you access sequential files on the application server using the following statements

  • OPEN DATASET
  • READ DATASET
  • TRANSFER
  • DELETE DATASET

the system automatically checks the user’s authorization against the authorization object S_DATASET. Based on the User Role and Authorizations the above activities will be possible.

Hence the developers must check the authorization in ABAP program before accessing the file using the function module AUTHORITY_CHECK_DATASET.

  • No labels