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

restrict multiple users from edit the data in custom tcode

Bharath84
Participant
0 Likes
4,051

Hi All,

In my module pool, I have two input fields and in application tool bar I have Create, Change and Display icons. For the given inputs user clicks on Create/Change and enter some data in the table controls and save the data into database. If one user is trying to Create/Change the data for the given inupts, other users should not be able to go Create/Change mode. Only Display mode should be allowed. I used the function module 'RSAU_WRITE_SM01_LOG' but still other users are able to go into change mode. How can we restrict this. Please let me know if anyone have done this.

Thanks,

Haritha

10 REPLIES 10
Read only

Sandra_Rossi
Active Contributor
2,932

I think you go completely the wrong way with RSAU_WRITE_SM01_LOG!

What you are looking for is a lock to be set when a user is editing the "object", and any other person trying to edit this same object will be rejected because a lock exists. Please search the forum for "lock object" (enqueue, dequeue, etc.)

Read only

IN
Contributor
2,932

Hello,

You should look at locking objects concept in SAP. There you can find the way to lock a table and what are the options when doing the locking.

For more information, be free to ask.

Regards,

Igor

Read only

dev_parbutteea
Active Contributor
2,932

Hi,

I do not know which object you are updating but you may use lock objects to restrict access (via enqueue & dequeue).

Read only

Gourab_Dey
Product and Topic Expert
Product and Topic Expert
0 Likes
2,932

You have to use the lock object. You will get enough information in google. So, basically when you create a lock object, 2 function module will be created. Once for en-queue that is to put a lock and another one is de-queue which is to release the lock. Once it's lock, you can see it in SM12.

Thanks,

Gourab

Read only

keremkoseoglu
Contributor
0 Likes
2,932

Create a custom (Z-) lock object for your T-Code. If a user can enqueue, he/she can edit. If not, he/she should see the data in read only mode.

Read only

ThangaPrakash
Active Contributor
2,932

@Haritha P It can be achieved by using lock object, create a lock object for the table which you are using in the Table control.

In the beginning of the program call created lock objects ENQUEUE to lock the data and at the end call DEQUEUE to release the lock

SAP Help Lock objects

Lock Object creation and consumption reference

Read only

0 Likes
2,932

Hi Prakash,

I have already used this ENQUE and DEQUE function modules in my module pool program when updating my custom tables. Here what I am trying to do is, if one user click on Change icon in application tool bar, all the tabs are in editable mode. If other users try to click on Change icon, it should throw an error message 'One user already editing the data, only display allowed'.

Thanks,

Haritha

Read only

2,932

vidya.p that's the use of Lock objects!

  1. Read if the object is locked
  2. If locked, throw error on edit
  3. if not locked, lock it and procede with editing.
  4. At save, release the lock
Read only

2,932

Generally speaking, to support mass update in background in parallel processes, between the read (1) and the lock (3), it could be locked by another process, so I think it's best to use this logic as rule of thumb:

  1. Try to lock the object (ENQUEUE)
  2. If locked, throw error on edit
  3. Otherwise proceed with editing.
  4. At save, release the lock
Read only

ThangaPrakash
Active Contributor
0 Likes
2,932

vidya.p If that is the case, under Change Icon user command, check for the lock entries using FM 'ENQUEUE_READ' and if there is lock for your transaction/program/table, then raise a message 'One user already editing the data, only display allowed'.