04-13-2012 12:23 PM
Hi,
As apart of performance i need to restrict the one custom report execution for 5 times only when users executed at the same time in parallel.
Any clues............
Regards
Ram
04-16-2012 12:10 PM
Intresting..
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
(01,02,03,04,05).
Check the below code
INITIALIZATION.
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
INTO v_key.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
* MODE_RSTABLE = 'E'
tabname = zconfig
varkey = v_key
* X_TABNAME = ' '
* X_VARKEY = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3
.
IF sy-subrc <> 0.
CLEAR V_CONFIG.
CONTINUE.
ELSE.
v_flag_ok = 'X'.
EXIT.
ENDIF.
ENDLOOP.
IF v_flag_ok IS INITIAL.
MESSAGE 'Max no. of user reached! cannot run report ' TYPE 'E'.
ENDIF.
ENDIF.
04-16-2012 11:44 AM
Hi,
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....
http://scn.sap.com/thread/1909186
regards,
Rajesh Sadula.
04-16-2012 11:59 AM
You could use a lock object, at start of execution try to enqueue the object with 5 different values (from key = value 1 to value 5) until success or reject with error, perform a commit, rollback or dequeue at end of report.
Regards,
Raymond
04-16-2012 12:10 PM
Intresting..
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
(01,02,03,04,05).
Check the below code
INITIALIZATION.
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
INTO v_key.
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
* MODE_RSTABLE = 'E'
tabname = zconfig
varkey = v_key
* X_TABNAME = ' '
* X_VARKEY = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3
.
IF sy-subrc <> 0.
CLEAR V_CONFIG.
CONTINUE.
ELSE.
v_flag_ok = 'X'.
EXIT.
ENDIF.
ENDLOOP.
IF v_flag_ok IS INITIAL.
MESSAGE 'Max no. of user reached! cannot run report ' TYPE 'E'.
ENDIF.
ENDIF.
04-16-2012 9:52 PM
Hi,
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.
Cheers,
Manu.
04-16-2012 10:21 PM
The trouble with using any sort of persistent objects to hold the entries is that they could persist after the program finishes (if it terminates abnormally say).
Lock objects are normally used for this requirement.
Rob
04-17-2012 10:49 AM
Hello Ram,
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.
BR,
Suhas
04-17-2012 2:31 PM
04-17-2012 2:40 PM
I know I am late to reply, but this could be another solution of your problem:
Regards,
Naimesh Patel