Application Development 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: 

lock objects

Former Member
0 Kudos

hi,

thanks in advance.

whats is a lock object why is it used for...

how it is declared......

...bye

7 REPLIES 7

Former Member

Hii

1)<b>Lock Objects</b>

<i>These types of objects are used for locking the access to database records in table. This mechanism is used to enforce data integrity that is two users cannot update the same data at the same time. With lock objects you can lock table-field or whole table.</i>

In a system where many users can access the same data, it becomes necessary to control the access to the data. In R/3 system this access control is built-in on database tables. Developers can also lock objects over table records.

To lock an object you need to call standard functions, which are automatically generated while defining the lock object in ABAP/4 dictionary. This locking system is independent of the locking mechanism used by the R/3 system. This mechanism also defines LUW i.e. Logical Unit of Work. Whenever an object is locked, either by in built locking mechanism or by function modules, it creates corresponding entry in global system table i.e. table is locked. The system automatically releases the lock at the end of transaction. The LUW starts when a lock entry is created in the system table and ends when the lock is released.

<b>Creating Lock Objects</b>

Lock object is an aggregated dictionary object and can be defined by using the following steps:

o From initial data dictionary screen, enter the name for the object, Click Lock object radiobutton and then click on Create. The system displays a dialog box for Maintain Lock Objects screen

o Enter short text as usual and the name for primary table.

-Save

-Select Tables option

From this screen you can:

Select secondary tables, if any, linked by foreign key relationship.

Fields for the lock objects. This option allows you to select fields for objects (R/3 system allows locking up to record level). Lock object argument are not selected by user but are imposed by the system and includes all the primary keys for the table.

1) Exclusive lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.

2) Shared lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.

3) Exclusive but not cumulative: Exclusive locks can be requested several times from the same transaction and are processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.

Also, last but not the least, locking the object is logical (locking with any enqueue ) .so, you have to use the lock object while trying to access from second program .

also check these links for more info..

<a href="http://<b>www.sap-img.com/abap/ type-and-uses-of-lock-objects-in-sap.htm</b>">http://<b>www.sap-img.com/abap/ type-and-uses-of-lock-objects-in-sap.htm</b></a>

Reward points if helpful..

Revert back for more help

Regards

Naresh

Former Member
0 Kudos

Hi,

Lock objects are used to synchronize access to the same data by more than one program.

http://help.sap.com/saphelp_46c/helpdata/en/cf/21ef0d446011d189700000e8322d00/frameset.htm

Pls chek this link:

http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm

Hope it helps you.

REgard,

Anjali

Former Member
0 Kudos

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.

<a href="http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm">SAP HELP</a>

and

<i>Hope This info Helps YOU.</i>

Regards,

Raghav<a href="http://techrepublic.com.com/5100-6329_11-5066352.html#">one more good link</a>

Former Member
0 Kudos

Lock objects :

simultaneous accessing of the same data record by 2 users in the SAP system is synchronized by lock mechanism.When dialog transactions are programmed , locks are set and released by calling certain function modules,These function modules are generated automatically from the definition of s0-called lock objects in the ABAP/4 Dictonary

chk this eample for lock objects

http://help.sap.com/saphelp_nw04s/helpdata/en/af/22ab01dd0b11d1952000a0c929b3c3/content.htm

Message was edited by: Chandrasekhar Jagarlamudi

Former Member

former_member188685
Active Contributor
0 Kudos

Hi,

The R/3 System synchronizes simultaneous access of several users to the same data records with a lock mechanism. When interactive transactions are programmed, locks are set and released by calling function modules (see Function Modules for Lock Requests). These function modules are automatically generated from the definition of lock objects in the ABAP Dictionary.

http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/62/af24413689dd2be10000000a1550b0/content.htm

Regards

vijay