‎2006 Nov 08 8:15 PM
Hello,
There is a requirement in which a warning message should be displayed if the same program is being executed by another user.
Please let me know incase there is any function module to find out the same or any other way to get the details.
Thanks,
Sushil
‎2006 Nov 08 8:22 PM
Hi Sushil
GO to SM12 and click the list
you 'll have the list of users accesing the same program
chk tis fm's
call function 'ENQUEUE_READ'
exporting gclient = gclient
guname = guname
gname = gname
garg = garg
importing subrc = subrc
tables enq = enq
exceptions others = 1.
call function 'ENQUE_READ'
exporting gclient = gclient
guname = guname
gname = gname
garg = garg
importing subrc = subrc
tables enq = enq.Revert back for more help
Regards
Naresh
‎2006 Nov 08 8:22 PM
Hi Sushil
GO to SM12 and click the list
you 'll have the list of users accesing the same program
chk tis fm's
call function 'ENQUEUE_READ'
exporting gclient = gclient
guname = guname
gname = gname
garg = garg
importing subrc = subrc
tables enq = enq
exceptions others = 1.
call function 'ENQUE_READ'
exporting gclient = gclient
guname = guname
gname = gname
garg = garg
importing subrc = subrc
tables enq = enq.Revert back for more help
Regards
Naresh
‎2006 Nov 08 8:22 PM
hi Naresh,
I want to find out programmatically.
i.e when I am executing a program and if the same is being executed by another person, then the program should give a popup message.
Thanks,
Sushil
‎2006 Nov 08 8:26 PM
Hi, if this is a custom program, you can lock it up during execution by using the lock object.
data: repid type sy-repid.
repid = sy-repid
call function 'ENQUEUE_E_TRDIR'
EXPORTING
MODE_TRDIR = 'X'
NAME = repid
* X_NAME = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc <> 0.
message w001(00) with 'Program in use by another user'.
endif.
Regards,
Rich Heilman
‎2006 Nov 08 8:29 PM
Hi Rich,
The proposed solution will only tell me that the program is being executed by another user.
Is it possible to find out who the other user id is ?
Thanks,
Sushil
‎2006 Nov 08 8:32 PM
Hi Naresh,
Thanks for the quick response.
Would the FMs suggested by you return the user id of the person who is currently executing the same program ?
Regards,
Sushil
‎2006 Nov 08 8:39 PM
Sorry try this.
report zrich_0001 .
data: repid type sy-repid.
repid = sy-repid.
parameters: p_check.
at selection-screen.
call function 'ENQUEUE_E_TRDIR'
exporting
mode_trdir = 'X'
name = repid
exceptions
foreign_lock = 1
system_failure = 2
others = 3.
<b>if sy-subrc = 1.</b>
<b> MESSAGE ID SY-MSGID TYPE 'W' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.</b>
endif.
When user hits enter on selection screen, warning message will appear with the locking user.
Regards,
Rich Heilman
‎2006 Nov 08 8:35 PM
Hi Sushil,
Exception 1 foreign lock
captures the user .
call function 'ENQUEUE_E_TRDIR'
EXPORTING
MODE_TRDIR = 'X'
NAME = repid
X_NAME = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
if sy-subrc = 0.
select single * from trdir where name = repid.
endif.
this will gve you the user.
Revert back for more help.
Reward points if helpful
Regards
Naresh
‎2006 Nov 08 8:39 PM
Thanks a lot Naresh.
I shall try this out tomorrow.
Regards,
sushil