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

Query on sap locks(ENQUEUE/DEQUEUE)

Former Member
0 Likes
1,708

Hi All,

should the sap locks ENQUEUE/DEQUEUE need to be used for all the updation/insertion of records ino the table?

Please confirm.Should this locking technique be used even for insertion of records into the table?

Regards,

Pra.

5 REPLIES 5
Read only

venkat_o
Active Contributor
0 Likes
922

Hi Prasad, ENQUEUE_/ DEQUEUE_ function modules should be called when u r updating/ inserting records to the tables which are normally updated or inserted using Transaction screens. for other tables not necessary. for example if u take VBAK or VBAP, these are generally updated using transactions. when u want to update them programmatically locks needs to be applied. I hope that it helps u . Regards, Venkat.O

Read only

Former Member
0 Likes
922

Hi,

Insertion or creation of records does not require locking mechanism.

U can refer to the below link for further info on Locking mechanism : http://help.sap.com/saphelp_46c/helpdata/en/cf/21eebf446011d189700000e8322d00/frameset.htm

Regards,

Mrunal

Intelligrp Inc.

Read only

Former Member
0 Likes
922

Hi,

Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.

SAP Provide three type of Lock objects.

- Read Lock(Shared Locked)

protects read access to an object. The read lock allows other transactions read access but not write access to

the locked area of the table

- Write Lock(exclusive lock)

protects write access to an object. The write lock allows other transactions neither read nor write access to

the locked area of the table.

- Enhanced write lock (exclusive lock without cumulating)

works like a write lock except that the enhanced write lock also protects from further accesses from the

same transaction.

You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.

Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.

Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.

Technicaly:

When you create a lock object System automatically creat two function module.

1. ENQUEUE_<Lockobject name>. to insert the object in a queue.

2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.

You have to use these function module in your program.

Hope this will give a basic idea.

Read only

Former Member
0 Likes
922

Hi,

Thanks for your replies.

But i am getting controvercy answers for the question Whether to have a lock for the insertion of the records?

Please give me the reasons of why if we need it and why not if we do not want a lock for insertion of records.

Regards,

Pra

Read only

0 Likes
922

Hi Prasad,

The use of lock objects is to lock the table while updating or inserting the records in a table.but when to use locking depends on the requirement.generally we will not use locking mechanism in our programs.if we want to use we have to call

ENQUE_LOCKOBJECT functional module first and then perform operations on the table and then call DEQUE_LOCKOBJECT functional module.when you call ENQUE fm the table is locked and nobody is able to change the content of the table but depending on the lock type they can read only.so if we have a program to insert records into a table.we checked the table primary key values.we inserted other than that values.but when you executing the program other person manually using sm30 or se11 entered the record that you want to uppdate.means the field is of int and have values 1,2,3,4.tyou want to insert from 5.but manually it is inserted.so u r program will go wrong means it will not inset that record.to avoid this type of things we will use locking.but generally at client side nobody will execute the transaction or program same time.so there is no problem if you will not locking also.but whether to use locking or not depends on the situation only

rewards points if helpful..