Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to stop the execution of one program from another program

Former Member
0 Likes
1,957

Hi Experts,

How can I restrict the execution of one program when another program is running such that when one program is running other cannot be executed in any session by the same user or a different user and same should happen when the other program is run?

Using Lock objects on table TRDIR or TADIR is not helping as it will provide restriction only from editing the other program while other is being run whereas my requirement is that it should prevent the other program from execution.

This is really urgent!

TIA

Abhishek

Edited by: abhishek singh on Feb 26, 2008 12:59 PM

Hi Experts,

How can I restrict the execution of one program when another program is running such that when one program is running other cannot be executed in any session by the same user or a different user and same should happen when the other program is run?

Using Lock objects on table TRDIR or TADIR is not helping as it will provide restriction only from editing the other program while other is being run whereas my requirement is that it should prevent the other program from execution.

This is really urgent!

TIA

Abhishek

Edited by: abhishek singh on Feb 26, 2008 12:59 PM

5 REPLIES 5
Read only

Former Member
0 Likes
1,510

Hi Abhishek,

Since no one has been able to provide an answer here ... may be I can suggest something (which might not be practical for you but still). Now since there isnt a method (until now) to determine whether a program is running in dialog mode or not via checking a DB table or some system parameters, you can do so that the two programs involved in this equation can ONLY be executed in background.

This would be possible ONLY if the programs are NOT interactive.

Now, you ensure the programs are executed only in background by preventing the program from being executed if SY-BATCH is INITIAL. (if background then sy-batch is set to 'X').

Now, when you try to execute program A you check whether there is any job running in the system with name of program B by checking table TBTCO with STATUS. If the job is active then the program should not be allowed to be scheduled.

Hence you before either program is allowed to be run two checks are performed:

1. There is no job running with the other program name

2. The current job is scheduled to run only in background

How realistic this sounds is up to your requirement. I hope it helps in some way though.

Cheers.

Read only

Former Member
0 Likes
1,510

Hi,

ENQUEUE_ESFUNCTION Lock an abap program so that it cannot be executed.

Can your try this FM..if it helps..pls let me know

santhosh

Read only

Former Member
0 Likes
1,510

Hi, you can try to lock an object when you launch the first program and check the same object when you launch the second program. If the object is lock you can finish the second program.

Regards.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,510

Lock objects should do the job. If you lock with an "E" exclusive lock in the different program. If you lock the same object only the first lock will be successfull, any object will do the job.

The two (or more) programs should begin with an ENQUEUE_Exxxx with MODE = 'E'.

Look at [The SAP Lock Concept (BC-CST-EQ)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCSTEQ/BCCSTEQ_PT.pdf]

Regards

Read only

Former Member
0 Likes
1,510

Use FM ENQUEUE_ESINDX .

Lets say,


1st program name = ZTEST
2nd program name = ZTEST1.

Change the source code of both the programs to call the above FM before the execution of both the programs. 
Pass a unique name say 

1. 1st program name (ZTEST) OR 
2. 2nd second program name (ZTEST1) OR 
3. 1st program name + 2nd program name (ZTEST-ZTEST1)

and RELID as 'ZZ'. 

This will help ONLY one program to be executed at a time.

Hope it helps.

<REMOVED BY MODERATOR>

Thanks... Balaji

Edited by: Alvaro Tejada Galindo on Feb 26, 2008 12:09 PM