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

Single instance of a program

Former Member
0 Likes
1,616

Hi guys,

My customer requires that a certain program is to be executed only one execution at a time (i.e. no two or more instances of the same program running on the same client ) does anyone know how to do that?

Hello,

You need to use (after the call):

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

One error message appears directly. In my case I changed the message's type to 'Information' (replace SY-MSGTY with 'I').

I hope it's useful.

Miquel.

6 REPLIES 6
Read only

Former Member
0 Likes
1,192

Hello,

You can use the lock concept [Lock and Unlock Program|https://wiki.sdn.sap.com/wiki/x/1m4].

Another way is to create a table with a flag record that defined if the program is currently running or not (set the flag when the program starts, unset it when finishes).

Regards.

Read only

Former Member
0 Likes
1,192

Another way is to check upfront that the program is being started by a specific transaction code (otherwise exit) and then lock the transaction if the user is authorized (but already in the transaction...). When the user leaves the transaction, it should again be unlocked.

You can check the authority and lock status of the transaction upfront in the program using FM AUTHORITY_CHECK_TCODE.

There are even some standard transactions which work in this way, from which you can get some sample coding and the correct functions to use...

Cheers,

Julius

Read only

0 Likes
1,192

Thank you for your replies. Actually i don't want to link the program to a transaction, and I don't want to lock the edition but the execution of the program, it's true that i could override the use of the edit lock field and use it as an "execution lock" but that wouldn't be the cleanest approach, would it? so do you have other suggestions

Read only

Former Member
0 Likes
1,192

Hi,

Use bellow given program. It may helpfule to you.

thanks

DATA : lv_zeit TYPE programs-zeit,

lv_prog TYPE programs-prog_name.

lv_zeit = im_subdir.

lv_prog = im_repid.

CALL FUNCTION 'ENQUEUE_ET_PROGS'

EXPORTING

  • MODE_PROGRAMS = 'E'

  • DATUM =

zeit = lv_zeit

prog_name = lv_prog

  • PID =

  • X_DATUM = ' '

  • X_ZEIT = ' '

  • X_PROG_NAME = ' '

  • X_PID = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

Read only

0 Likes
1,192

Hi Vijetha,

The function module works fine, but there is a little change in the requirement, my customer wants a popup message containing the login of the user who is currently executing it, do you know how to do that?

Read only

0 Likes
1,192

Hello,

You need to use (after the call):

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

One error message appears directly. In my case I changed the message's type to 'Information' (replace SY-MSGTY with 'I').

I hope it's useful.

Miquel.