‎2006 Jul 26 8:02 PM
Hi All,
Is there any way that i can make the program run at a time only once, so that if one instance of it is running it should give a message to others saying program is already running.
Let me know is there any other way of doing it..
Thank You,
Suresh
‎2006 Jul 26 8:11 PM
hi babu,
create a z table (for eg,zvalidate) with a field (for eg,flag)of length 1 and type char.
in the program you can check
select single * from zvalidate into wa where flag = space.
if sy-subrc ne 0 .
<throw error message?
else.
<your report's executable statements>
UPDATE zvalidate set flag = 'X'.
endif.
Cheers,
Abdul Hakim
‎2006 Jul 26 8:06 PM
You can import a variable intially and if it is set to X, do NOT execute the program and exit. Export a different value at the end of the program to that variable.
Regards,
Ravi
‎2006 Jul 26 8:10 PM
Hi Ravi,
Your solution seems to be quite interesting, can you please explain it more clearly ? Please attach the piece of code if available .
Regards,
Varun .
‎2006 Jul 26 8:09 PM
Hi,
Please check this sample code from other thread.
Make sure that no one else is running this program
This is the locking mechanism for this program.
PROGRAM_NAME = SY-REPID.
CALL FUNCTION 'ENQUEUE_ESINDX'
EXPORTING
SRTFD = PROGRAM_NAME
SRTF2 = 0
_WAIT = 2
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2.
IF SY-SUBRC <> 0.
*Give message that someone is running the program
ENDIF.Hope this will help.
Regards,
Ferry Lianto
‎2006 Jul 26 8:10 PM
Depends on whether it should be a userspecific or across the system.
If across the system then you need to flag in Z table at initial event start-of-selection and clear the flag at end of the program.
If with in the user's sessions use SET Parameter option.
Regds
Manohar
‎2006 Jul 26 8:11 PM
‎2006 Jul 26 8:11 PM
You can use a lock object for the program.
report zrich_0001.
parameters: p_check.
at selection-screen output.
data: program type sy-repid.
program = sy-repid.
call function 'ENQUEUE_EPROG'
exporting
mode_trdir = 'E'
programm = program
* X_PROGRAMM = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
exceptions
foreign_lock = 1
system_failure = 2
others = 3
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Regards,
Rich Heilman
‎2006 Jul 26 8:11 PM
hi babu,
create a z table (for eg,zvalidate) with a field (for eg,flag)of length 1 and type char.
in the program you can check
select single * from zvalidate into wa where flag = space.
if sy-subrc ne 0 .
<throw error message?
else.
<your report's executable statements>
UPDATE zvalidate set flag = 'X'.
endif.
Cheers,
Abdul Hakim
‎2006 Jul 26 11:13 PM
Hi All,
I want the program not to be executed by others when some body else is already running or using the program.
I tried doing all the solutions.. given by you all... but its not working for me..
i am working in 4.0 B version of SAP..FYI.
thank you,
Suresh
‎2006 Jul 26 11:57 PM
‎2006 Jul 27 12:48 AM
when i write the code its stopping the control from not editing the program.. but not executing the program..
‎2006 Jul 27 12:51 AM
Copy and paste the program code that I've provided, activate the program, now back out of the editor and run it directly from the first screen of SE38. Leave it on the selection screen. Open another session and run the program again. Since the other session is currently running the program, you should get a message right away when running the program in the other session. Is this not happening?
Regards,
Rich Heilman
‎2006 Jul 27 1:02 AM
‎2006 Jul 27 1:03 AM
I want no body else to run the program when.. for eg: i am running it..
‎2006 Jul 27 1:05 AM
Suresh, this is exactly how my example program works in my r/3 system. It will not allow me to run it while its being ran in another session. Not sure why its not working for you. Are you sure that the lock is being applied. Run the program and let it sit on the selecition screen, now go to another session and go to SM12. Check to see if a lock exists.
Regards,
Rich Heilman
‎2006 Jul 27 1:11 AM
Sorry.. i didnt tell u this before..
There is no function module ENQUEUE_EPROG in 4.0 B, i am using ENQUEUE_ES_PROG.
Pls suggest.
Suresh
‎2006 Jul 27 1:23 AM
‎2006 Jul 27 1:28 AM
Please try this example. This works good in my system.
report zrich_0001.
data: program type sy-repid.
parameters: p_check.
load-of-program.
program = sy-repid.
call function 'ENQUEUE_ES_PROG'
exporting
* MODE_TRDIR = 'E'
name = program
* X_NAME = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
exceptions
foreign_lock = 1
system_failure = 2
others = 3
.
if sy-subrc <> 0.
message e001(00) with 'Program currently in use'.
endif.
Regards,
Rich Heilman
‎2006 Jul 27 1:36 AM
Hi Rich,
It is working now.. but when the message is displayed i dont see the selection screen contents.. on the screen..
if sy-subrc <> 0.
set cursor field 'P_FL_UNX'.
set screen 0.
message e009(zmd) with 'Program is in use by other user'.
leave to list-processing.
endif.
though i used the above code it still not showing up the values..
any help on this...
Suresh
‎2006 Jul 27 1:39 AM
‎2006 Jul 27 1:39 AM
‎2006 Jul 27 1:40 AM
If so, try doing the lock in the start-of-selection instead.
report zrich_0001.
data: program type sy-repid.
parameters: p_check.
<b>start-of-selection.</b>
program = sy-repid.
call function 'ENQUEUE_ES_PROG'
exporting
* MODE_TRDIR = 'E'
name = program
* X_NAME = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
exceptions
foreign_lock = 1
system_failure = 2
others = 3
.
if sy-subrc <> 0.
message e001(00) with 'Program currently in use'.
exit.
endif.
This will before the lock only when the user executes from selection screen.
Regards,
Rich Heilman
‎2006 Jul 27 1:44 AM
It is giving me the message in a blank screen.. not in the same screen as selection screen
‎2006 Jul 27 1:51 AM
‎2006 Jul 27 2:18 AM
‎2006 Jul 27 2:21 AM
‎2006 Jul 27 2:28 AM
‎2006 Jul 27 2:41 AM