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

Program being processed by another user

Former Member
0 Likes
1,021

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
867

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

8 REPLIES 8
Read only

Former Member
0 Likes
868

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

Read only

0 Likes
867

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

Read only

0 Likes
867

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

Read only

0 Likes
867

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

Read only

0 Likes
867

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

Read only

0 Likes
867

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

Read only

Former Member
0 Likes
867

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

Read only

0 Likes
867

Thanks a lot Naresh.

I shall try this out tomorrow.

Regards,

sushil