Ask basis person to create authorization for that report, and give permission to specific users only.....
It might help you....
Go to the below link....
As Rajesh suggested limit the number of people having authoriztion.
I can think of a work around.
Create a customizing table say with just 2 key feilds
Report name and Lock index .
Say if you want the report to restrict to five user then matintain 5 rows and with same report name and lock index
Check the below code
DATA : v_key TYPE rstable-varkey,
v_flag_ok TYPE char1.
*zconfig has keys mandt repname lockindex.
SELECT * FROM zconfig
INTO TABLE it_zconfig WHERE repname = sy-repid.
IF sy-subrc = 0.
LOOP AT it_zconfig ASSIGNING <fs_zconfig>.
CONCATENATE <fs_zconfig>-mandt <fs_zconfig>-repname <fs_zconfig>-lockindex
CALL FUNCTION 'ENQUEUE_E_TABLE'
* MODE_RSTABLE = 'E'
tabname = zconfig
varkey = v_key
* X_TABNAME = ' '
* X_VARKEY = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
foreign_lock = 1
system_failure = 2
OTHERS = 3
IF sy-subrc <> 0.
v_flag_ok = 'X'.
IF v_flag_ok IS INITIAL.
MESSAGE 'Max no. of user reached! cannot run report ' TYPE 'E'.
I would rather play with an IMPORT/EXPORT..FROM/TO DATABASE indx(xy) at start and end of your program... you could import the current running number of programs with IMPORT statement at initialization event and increase it by one, and the reverse operation at the end with an EXPORT.
No need to create ddic object here.
There is no need to create a custom table. And as Rob has already highlighted what problems the custom table data might pose - what if your program terminates & the table entries are not cleared?
You can build you solution using Lock objects without the need to store any persistent data.
START-OF-SELECTION. DATA: gt_enq_list TYPE STANDARD TABLE OF seqg3 INITIAL SIZE 0, gv_count TYPE i, gv_arg TYPE eqegraarg. gv_arg = sy-repid. "Argument of the report * Check the no. of lock entries CALL FUNCTION 'ENQUEUE_READ' EXPORTING gname = 'ZRESTRICTREPORT' garg = gv_arg GUNAME = '*' IMPORTING number = gv_count TABLES enq = gt_enq_list EXCEPTIONS communication_failure = 1 system_failure = 2 OTHERS = 3. IF sy-subrc = 0 AND gv_count > 5. MESSAGE 'Maxm. number of users running the report' TYPE 'E'. ENDIF. * Set the lock on the report execution CALL FUNCTION 'ENQUEUE_EZRESTRICTREP' EXPORTING report = sy-repid _scope = '1' EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3. IF sy-subrc <> 0. * Error handling ENDIF. END-OF-SELECTION. * Release the lock after the execution is complete CALL FUNCTION 'DEQUEUE_EZRESTRICTREP' EXPORTING report = sy-repid _scope = '1'.
So even if your program terminates, the lock object will be enqueued & the lock counter will be reduced by 1!
Hope i'm clear.
I know I am late to reply, but this could be another solution of your problem: