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

Locking issue

Former Member
0 Likes
1,223

Hello All

I have one custom T code.

When I run this, I get some records in ALV and some buttons to do some functions.

I dont want to allow 2 users to make above functions in the same time.

So I want to catch, which user already running this T code.

Please help on this.

Regards

Ram

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,165

Hi,

You could use Function Module: 'TH_LONG_USR_INFO' to check which users are currently using your transaction.

Best Regards,

Martin

10 REPLIES 10
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,165

Check SM04 it will have entry of the use running the tocde.

use the following command

DATA: BEGIN OF USR_TABL OCCURS 10.
          INCLUDE STRUCTURE USRINFO.
  DATA: END OF USR_TABL.
call 'ThUsrInfo' id 'OPCODE' field opcode_list
  id 'TABUSR' field usr_tabl-*sys* .

USR_TABL will have the details

Nabheet

Edited by: nabheetmadan09 on Jan 3, 2012 1:37 PM

Read only

Former Member
0 Likes
1,166

Hi,

You could use Function Module: 'TH_LONG_USR_INFO' to check which users are currently using your transaction.

Best Regards,

Martin

Read only

0 Likes
1,165

I think this FM 'TH_LONG_USR_INFO' gived based on User name.

But I want to catch User name based on T code.

Is there any way to catch User name based on T code?

Please help on this?

Thanks

Ram

Read only

0 Likes
1,165

Hi,

If you parse '*' as user name you will get an internal table of all current sessions. You should be able to loop at this table based on transaction code.

Regards,

Martin

Read only

0 Likes
1,165

try to use below mentioned command

DATA: BEGIN OF USR_TABL OCCURS 10.
          INCLUDE STRUCTURE USRINFO.
  DATA: END OF USR_TABL.
call 'ThUsrInfo' id 'OPCODE' field opcode_list
  id 'TABUSR' field usr_tabl-*sys* .

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,165

Before that please explain

I dont want to allow 2 users to make above functions in the same time

What functions ??

What if the function is available through standard transactions ??

Kesav

Read only

Former Member
0 Likes
1,165

Rama,

you know what!! use Import export... easy way to capture..

user one .

clicks a button, export a FLAG to a memory id.

user two

clicks the same button, check(import) the FLAG from memory. if the flag is set that means some one is using it..

after user one is done with his work

clear the memory id.

now user two can use it as flag is free,

now set the flag for user two

Read only

0 Likes
1,165

@Soumyaprakash - Import/Export wouldn't work in this case.

@Ram

When I run this, I get some records in ALV and some buttons to do some functions.

I dont want to allow 2 users to make above functions in the same time.

So I want to catch, which user already running this T code.

Do you want to make this specific to the function or the record chosen on the ALV against which the function is to be performed?

Provide more details on the function that you want to perform on clicking the button etc.

Regards,

Chen

Read only

0 Likes
1,165

Chen ..

correct.. its a different call sequence. .import export wont work. i dint read it i guess..

1. go for a lock object. in this case you need to create lock object, activate lock object FMs and use them. or

2. create a SET/GET parameter for yourself and use that..

when button is clicked,

get PARAMETER ID 'ZSOMU' FIELD lv.
IF lv NE 'X'.
  lv = 'X'.
set PARAMETER ID 'ZSOMU' FIELD lv.
"continue processing
"and at the end assign a blank value back to the parameter 
else.
  message 'Already processing ' type 'E'.
ENDIF.

Edited by: Soumyaprakash Mishra on Jan 3, 2012 3:45 PM

Read only

abdulbasit
SAP Mentor
SAP Mentor
0 Likes
1,165

Hi Ram,

Instead of this approach, you may create your own lock object and use this object to lock when someone uses any function in your program. Then, you can check the lock when users try to run the same function. It will be easier to manage and monitor.

Abdulbasit.