Program Enqueue
Hi ,
Would like to know if there is a way to enqueue a program. My objective is to prevent users from running the program if some one esle is already executing it either in foreground or background.
I am in Ver 4.6c
Thanks in advance for your answers.
MGK
Hi,
One way I know to prevent running the program if its already running in background is calling FM BP_JOB_SELECT_SM37B in the program. If the returned table isnt empty the job is running.
Regards.
Have a look at lock object E_DSVAS_TRDIR, and use that in the program at initialisation.
_________________
Regards
R
Abap KC
SFMDR
Try this.
report zybt1pgm.
data: prg like indx-srtfd. prg = sy-repid.
do 2 times. wait up to 3 seconds. enddo.
call function 'ENQUEUE_ESINDX'
exporting relid = 'ZZ'
srtfd = prg
srtf2 = 0
exceptions foreign_lock = 1
system_failure = 2.
format color col_negative inverse on.
if sy-subrc ne 0.
write: / 'ERROR: Another User Is Already Running This Program.'.
write: / 'Program', prg, 'has been stopped. Rerun in 1 minute.'.
stop.
else.
write: / '*OK* ',prg.
endif.
Try this.
report zybt1pgm.
data: prg like indx-srtfd. prg = sy-repid.
do 2 times. wait up to 3 seconds. enddo.
call function 'ENQUEUE_ESINDX'
exporting relid = 'ZZ'
srtfd = prg
srtf2 = 0
exceptions foreign_lock = 1
system_failure = 2.
format color col_negative inverse on.
if sy-subrc ne 0.
write: / 'ERROR: Another User Is Already Running This Program.'.
write: / 'Program', prg, 'has been stopped. Rerun in 1 minute.'.
stop.
else.
write: / '*OK* ',prg.
endif.
Where do you mention the program name ?? Using the Enqueue that I mentioned, E_DSVAS_TRDIR you use the actual program name you are running therefore when you show the lock in SM12 the information mean something. With this lock all you will see is 'ZZ'. Also by using this enqueue which makes no reference to the report you are running, you cannot lock multiple programs - when one is locked, attempting to use the same technique on another program will result in that program reporting falsely that it is already running.
_________________
Regards
R
Abap KC
SFMDR