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

lock objects creation

Former Member
0 Likes
1,448

hai all.

what is lock object . wat is exact use of lock object .

can u send me simple example on lock object .

is it mainly used for module pools or else .

give me brief ....

Tanx in advance ..

10 REPLIES 10
Read only

matt
Active Contributor
0 Likes
1,343

Search this site of LOCK OBJECTS. or ENQUEUE. Read the help.

Search first - ask second.

matt

Read only

Former Member
0 Likes
1,343

Hi matthiew,

Please dont use hard words..many times its difficult for new joiner to search..so better help him in searching and give links hope you will take this in right spirit

Edited by: Madan Gopal Sharma on Jul 1, 2008 8:47 AM

Read only

matt
Active Contributor
0 Likes
1,343

>

> Hi matthiew,

>

> Please dont use hard words..many times its difficult for new joiner to search..so better help him in searching and give links hope you will take this in right spirit

>

> Edited by: Madan Gopal Sharma on Jul 1, 2008 8:47 AM

Better the poster reads the rules, follows them, and cuts down on the useless noise in the forum.

If anyone posts a question which shows they've attempted to help themselves, you'll find me very helpful.

Do you want the benefit of my experience, or do you want to feel good about yourself?

matt

Read only

JoffyJohn
Active Contributor
0 Likes
1,343

locking is required to prevent multiple acess to same data.

For example if you are changing a PO.

A check is required to prevent editing of the same PO at the same time by some one else.

For this purpose SAP use the concept of locking.

This technique is used for data consistency and integrity.

check this links for more details

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

Read only

JoffyJohn
Active Contributor
0 Likes
1,343

check this link for example

[http://www.geocities.com/rmtiwari/main.html?http://www.geocities.com/rmtiwari/Resources/Utilities/ABAPReference/ABENSAP_LOCK.htm|http://www.geocities.com/rmtiwari/main.html?http://www.geocities.com/rmtiwari/Resources/Utilities/ABAPReference/ABENSAP_LOCK.htm]

Read only

naveen_inuganti2
Active Contributor
0 Likes
1,343

Hi....

Not only for module pool.. where ever you want to restrict multi user Data fetching and modifying from the database table... there you can go for lock object...

So after cretaing the lock object it can generate two function modules...

one is to lock and other one is to open the lock...

they are always.. like....

ENQUEUE_<se11 lock object name>

and

DEQUEUE_<se11 lock object name>

to create lock object...

1. Enter the name starting with EZ in the SE11 and click on create...

2. Enter the short text.

3.Give your table name under TABLES tab PRIMARY TABLE block

4. Set the Lock mode.. . ex: Exclusive , Not cumulative( u can c documentaion for this)

5. Activate

6. Goto->lock modules... u can get two function modules like above...

7. thats is ur lock object cretaed...

now in the program whre ever u want to tetch the data from that table...

before select statement...call this function moduel..

> CALL FUNCTION 'ENQUEUE_<lo name>'

> EXPORTING

> MODE_ZLOAN_REIM = 'X'

> MANDT = SY-MANDT

> <keyfld> = <value variable>

> X_ZEMP_CODE = ' '

> _SCOPE = '2'

> _WAIT = ' '

> _COLLECT = ' '

> EXCEPTIONS

> FOREIGN_LOCK = 1

> SYSTEM_FAILURE = 2

> OTHERS = 3.

> IF SY-SUBRC <> 0.

> MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

> WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

> ENDIF.

Thanks,

Naveen.I

Read only

Former Member
0 Likes
1,343

Select object type Lock object in the initial screen of the ABAP Dictionary, enter an object name and choose Create. The name of a lock object should begin with an E (Enqueue).

The maintenance screen for lock objects is displayed.

Enter an explanatory short text in the field Short text.

You can then use the short text to find the lock object at a later time, for example with the R/3 Repository Information System.

Enter the name of the primary table of the lock object.

All other tables in the lock object must be linked with the primary table using foreign keys. There are also some restrictions on the valid foreign key relationships.

Select the lock mode of the primary table in the field below it.

The lock mode is used as the default value for the corresponding parameters of the function modules generated from the lock object.

Choose Add if you want to lock records in more than one table with the lock object.

A list of all the tables linked with the primary table using valid foreign keys is displayed. Select the appropriate table. The lock mode of the primary table is copied as lock mode. You can change this setting as required, for example you can assign the lock mode separately for each table.

Similarly, you can add a table linked with the secondary table just added with foreign keys. To do this, place the cursor on the name of the secondary table and choose Add.

If no lock mode is assigned to a table, no lock is set for the entries in this table when the generated function modules are called. You should not assign a lock mode if a secondary table was only used to define a path between the primary table and another secondary table with foreign keys.

Save your entries.

A dialog box appears in which you have to assign the lock object a development class.

You can (optionally) exclude lock parameters (see lock objects) from the function module generation on the Lock parameter tab page. This makes sense for example if you always want to lock a parameter generically.

To do this, simply deselect the Weight flag for the parameter. The parameter is not taken into consideration in the generated function modules. This parameter is then always locked generically.

The name of a lock parameter is usually the name of the corresponding table field. If two fields with the same name are used as lock parameters in the lock object from different tables, you must choose a new name for one of the fields in field Lock parameter.

You can define whether the function modules generated from the lock object should be RFC-enabled on the Attributes tab page.

If you set the Allow RFC flag, the generated function modules can be called from within another system with Remote Function Call.

If you permit Remote Function Calls for an existing lock object, you must ensure that the generated function modules are called from within an ABAP program with parameters appropriate for the type. You should therefore check all programs that use the associated function modules before activating the lock object with the new option.

Choose Activate.

Lock Modes :

The lock mode controls whether several users can access data records at the same time. The lock mode can be assigned separately for each table in the lock object. When the lock is set, the corresponding lock entry is stored in the lock table of the system for each table.

Access by more than one user can be synchronized in the following ways:

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.

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.

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.

Read only

Former Member
0 Likes
1,343

Hi,

Lock Objects

The SAP 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.

How many types of lock objects?

How to create Lock objects?

What is the main use of it in real time?

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.

Read only

Former Member
0 Likes
1,343

Hi,

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 when 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 defined 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 lock at the end of transaction.

Creating lock objects.

From initial SE11 screen, enter the name for the object and then click create. The system displays a dialog box for maintain lock objects screen.

Enter short text and name the primary table.

save.

select the tables option.

select the secondary tables, if any linked by foreign key.

select the fields for the lock objects. (This will lock upto record level)

When you activate the object the lock object the functions Enqueue_lockobject, dequeue_lock onject are automatically generated.

Ene queue is used to lock the record in the transaction or report program and dequeue is used to release the lock.

Types of locks:

1.Exclusive: modified and displayed by single user.

2.Shared: several users can access simultaneously in display mode but can be modified single user the first one.

3.Exclusive not cumulating: similar to exclusive lock but can be called several times from the same transaction.

Reward if useful.

Read only

Former Member
0 Likes
1,343

hi

i hope the following link will help you.

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

regards,

sravan.