Control List Save Option in a ABAP Report

When we try to download the list using the menu System->List-Save, function module "DOWNLOAD" will be called. DOWNLOAD Function module will perform a dynamic authorization check if the program and subroutine names are set.

Save-ABAP-Report-1

The program and subroutine names can be set using the function module SET_DOWNLOAD_AUTHORITY which is present in the same function group (GRAP).

Program ZZDEMO

CALL FUNCTION 'SET_DOWNLOAD_AUTHORITY'
     EXPORTING
          form = 'CHECK_AUTH'
          prog = 'ZZDEMO_AUTH'.
 
WRITE:/ 'Hello'.

In the above program we are setting the program(ZZDEMO_AUTH) and subroutine (CHECK_AUTH) to check the authorization for list download before generating the list output. In program ZZDEMO_AUTH we will implement a subroutine CHECK_AUTH and write the authorization logic inside the subroutine.

Program ZZDEMO_AUTH

*---------------------------------------------------------------------*
*       FORM check_auth                                               *
*---------------------------------------------------------------------*
FORM check_auth USING result TYPE i.
  result = 1.
ENDFORM.

If the subroutine returns any value other than zero (i.e. result = 1 in the above case ), then the following message will be displayed and the list will not be downloaded.

Save-ABAP-Report-2