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

Select single for update not creating lock on entry

Former Member
0 Likes
963

Hi All,

I want to update an entry from MARA table so what ii did is

select single for update * from mara where matnr = 'ZYS'.

The for update is supposed to create a lock for me and the the lock is released after the commit or roll back.

I'm running this prg in debug mode and after the statment

select single for update * from mara where matnr = 'ZYS''.

I opened MM02 for this material and could change the data which i'm not supposed to be as there is lock on this particular mater from single for update statemnt

or

I even tried from other program

select single * from mara where matnr = 'ZYS'. in debug mode and it returned a sy-subrc eq 0.

and i don't see a lock in SM12 FOR SELECT * FOR UPDATE.....

Can anyone clarify on this

Thanks

David

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
786

When using the FOR UPDATE, you are applying a lock at the DB level, not the application level. I believe that MM02 will always use the lock object to put locks on material master tables. You can only see lock object locks in SM12, this is why you don't see them when using the FOR UPDATE. I would suggest using a lock object for the material master tables instead of the FOR UPDATE.

You can find the lock object via SE11

REgards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
787

When using the FOR UPDATE, you are applying a lock at the DB level, not the application level. I believe that MM02 will always use the lock object to put locks on material master tables. You can only see lock object locks in SM12, this is why you don't see them when using the FOR UPDATE. I would suggest using a lock object for the material master tables instead of the FOR UPDATE.

You can find the lock object via SE11

REgards,

Rich Heilman

Read only

Former Member
0 Likes
786

I don't use this variant, so I'm not entirely sure what happens.

But I think this will create a lock at the database level, not an SAP lock. To lock the record, you should use the ENQUEUE functions.

Rob

Read only

Former Member
0 Likes
786

Hi,

Using the select/Insert/update/delete statement on the MARA table for Matnr will not lock the Material number from accessing through MM02 tcode.

To lock the Matnr you need to call the ENQUEUE and DEQUEUE FM .

Search the SCN for ENQUEUE and DEQUEUE / Lock objects..

Read only

0 Likes
786

Hi All,

I knew we can create a lock object but thought to give a shot without creating lock object.

So i'm just curious to know when we can use select * for update

F1 Help says select * for update creates an E type lock- which will prevent other locks(X AND S type locks) overwriting or even reading that entry

Also ,

can someone throw some light DB lock and SAP Lock ( is this same as SAP LUW and DB LUW)

Thanks

David