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

How to Lock a data base table for write access.

Former Member
0 Likes
997

Hi All,

I have a requirement where in I have to insert a bunch of data into a standard table using some function module. I want to lock the table for the others to insert/modity the records during my insertion. Please help me provide the procedure how to lock a table for write access for others.

thanks and regards,

Naresh

9 REPLIES 9
Read only

Former Member
0 Likes
935

Hi,

Activating a lock object in the ABAP Dictionary automatically creates function modules for setting (ENQUEUE_<lock object name>) and releasing (DEQUEUE_<lock object name>) locks.

then you can use the ENQUEUE_<lock object name> in program or FM for locking the table.

A lock object is first need to be created between table which are used.

Manish

Read only

0 Likes
935

Hi Manish,

Thanks for your update. But I already tried it. In that process I can only lock the table for a particalar entry each time. But I want to lock the table for a bunch of entries at a single shot. Because I am doing a mass update.

thanks and regards,

Naresh

Read only

0 Likes
935

Hi,

Try function Module 'ENQUEUE_E_TABLE' and 'DEQUEUE_E_TABLE'.

Regards,

Himanshu Verma

Read only

0 Likes
935

Hi Naresh,

When you say "the others to insert/modity the records during my insertion", you need to determine how those other change the table and find the lock object that uses (transaction SM12). If that locks entries in the table individually, that's what you might have to do.

Regards,

Nick

Read only

0 Likes
935

Hi Verma,

what should be passed to VARKEY. If possible can you please give me an axample.

thanks,

Naresh

Read only

0 Likes
935

Hi,

VARKEY is an optional parameter this is used is you want to lock the table based on certain field values like if you want to lock BKPF based on company code then you ahve to pass that to this variable if you want to lock table irrespective of any vlaues you can just pass the table name to this function module and that should do the trick...

Regards,

Himanshu Verma

Read only

0 Likes
935

Hi,

If you want to apply for bunch of records , you can use loop for it .

LOOP.

" some processing

PERFORM lock record. " ENQUEUE

" some processing again

APPEND record TO update_table.

ENDLOOP.

Thanks

Manish

Read only

Former Member
0 Likes
935

Hi,

Please go to this link.It may help you.

http://help.sap.com/abapdocu/en/ABENDB_LOCK.htm

Rewsrd if helpful.

Thanks,

LN