‎2007 Nov 13 9:28 AM
Hi experts,
I have came across a situation, before executing one program, i have to check weather other program is running or not.
Lets say I have 2 programs, program 1 and program 2.
1. If I want to run the pg 1, in foreground, I have to check weather prg 2 is running either in foreground or in background. If it is running in both the conditions, I have to raise an error message at the time of execution of prg 1 itself.
2. If I want to scedule the prg 1. At the time of its execution in background, it should check that prg 2 is not running at all (neither foreground nor background). If the prg 2 is running, prg 1 should, either wait till prg 2 gets executed or get rescheduled.
Please provide me your valuable suggestions.
Regards,
Ganesh V Khumse.
‎2007 Nov 13 10:56 AM
I think you have to use
CALL FUNCTION 'ENQUEUE_ESINDX'
twice. i.e. in prog1 with the progname prog1 and in prog2 with same progname i.e. prog1.
i.e. use same coding in two prog with same progname.
now when prog1 is running you can not run prog2.
check it may work.
regards
shiba dutta
‎2007 Nov 13 9:48 AM
Hi Ganesh,
For all these below problems we have to use function module <b>'ENQUEUE_ESINDX'</b>, pass program name; if sy-subrc ne 0 then someone is running the program.
Below is sample code.
CALL FUNCTION 'ENQUEUE_ESINDX'
EXPORTING
MODE_INDX = 'E'
MANDT = SY-MANDT
SRTFD = 'program name'
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
Hope it will solve ur problem.
Regards
Krishnendu
‎2007 Nov 13 10:29 AM
Hi Krishnendu Laha,
Thanks for the reply. When I tried to use this FM, the FM is taking only that program itself into consideration.
for Ex.
I passed the PRG 2 to the Function module, run the PRG 2 and after that I run the PRG 1 in which I am calling that FM. Even the PRG2 was running it was not giving the SY-SUBRC <> 0.
Interestingly for the same coding as above, when I run the PRG 1 and after that again I run the PRG 1. Now the FM is working properly.
That means this FM is only for the same program and not for the other program. I need to chcek the other program running or not.
Or is there something we are not passing to the FM and because of which we are getting this situation.
Please help.
Ganesh
‎2007 Nov 13 9:57 AM
call function 'ENQUEUE_READ'
exporting
gclient = gclient
guname = guname
gname = gname
garg = garg
importing
subrc = subrc
tables
enq = enq
exceptions
others = 1.
the above fn module helps to read the lock entries
‎2007 Nov 13 10:56 AM
I think you have to use
CALL FUNCTION 'ENQUEUE_ESINDX'
twice. i.e. in prog1 with the progname prog1 and in prog2 with same progname i.e. prog1.
i.e. use same coding in two prog with same progname.
now when prog1 is running you can not run prog2.
check it may work.
regards
shiba dutta
‎2007 Nov 13 11:29 AM
Hi Shiba,
I think it is working now. Thanks ..... but can you give me a favor and explain it why it is happening like that.
Things are working but I didn't get the exact logic behind it.
Once again thanks.
Ganesh
‎2007 Nov 14 3:56 AM
I think when you are locking the prog1 by enque fm then it will not release the lock until it process completely. So if in prog2 again you are trying to lock it it will return the sy-subrc ne 0. But you can face some problem when prog2 will also run then you cant run prog1 also. Because in prog2 also you are locking the prog1 as well.
regards
shiba dutta
‎2007 Nov 14 6:37 AM
Hi Shiba,
Things are clear now. Thanks for your replay and anyway I think I willl not get any probelm, because I have to it like that only, I mean if prg 1 is running it should not run prg2 and VICE VERSA.
So it is working for me!
Thanks a lot,
Ganesh