‎2009 May 01 7:51 AM
Hi All,
I have program called ZLOADFILE and it runs in background. my requirement is when i schedule the program ZLOADFILE in background ,i have to check if this program is already been running in background by any user , if it is already running then my job should be cancelled.
Please help me know if there is any functionality.
Thanks in Advance,
Neha
‎2009 May 01 8:22 AM
Hi.
I think, you can create some table and define lock object for it with write mode.
In program you should place code of locking that table.
After attempt of setting lock, check FOREIGN_LOCK exception of
corresponding function module.
If exception is raised, this means that one program already works.
‎2009 May 01 8:28 AM
Hi Neha,
Create a lock entry while running the program so that other users may not be able to run ur program.
Try to create one lock object and using the generated function module which sounds like enqueue_*****
lock the program from being executed by another user while running.
To chk whether ur lock is successful or not goto tcode sm12 and chk the entries.if its successful u will find an entry with program name.
regards,
Lakshman.
‎2009 May 01 9:24 AM
Use the Following FM to check wether the program is locked or not.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = ' '
gname = 'TRDIR'
garg = lw_uname
guname = ' '
TABLES
enq = lt_locked
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.Regards,
Gurpreet