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

Former Member
0 Likes
2,471

Hi ,

How to create Lock Objects for Z**** Tables ( Steps ). How to check ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,495

So using ABAP report we do some Processing in TABLES , That time no uses will be able to do any update to Data base Table . Right ?

That Processing may be UPDATING DB table ?

Can you tell some Real Time Scenarios Where LOCK is Used ?

Which SAP Defined tables are used Frequently in LOCKING mechanism ?

This will solve my issue .

11 REPLIES 11
Read only

Former Member
0 Likes
1,495

chk this

Read only

Former Member
0 Likes
1,495

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.

Please also check this link

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

Read only

Former Member
Read only

Former Member
0 Likes
1,495

Check the below thread:

Read only

Former Member
0 Likes
1,495

Say for example i have a user defined table ZSALES . The field SDNO will be having SD Number in new document is created ..

I created a lock object for SDNO in ZSALES table .

My question now ?

<i>Now to use this Lock object in Report ? I mean if i use ENQUEE Function in any report to see list of SDNO at the moment , will it makes the system not to store any data till the report is runing</i> .

If i dont Give DEQUEE what will happen ?

Read only

0 Likes
1,495

Hi Kumar,

Its like this:

If you have a table, you will have to have a mechanism to update the records of the table. Care must be taken that no two users can access the same record to update. To do this we proceed as follows in the program.

call function 'ENQUE<lockobject name>'.

Do update logic for the table.

call function 'DEQUE<lockobject name'..

If we do not use the deque function module, the record will be locked for further updating(Until the program completes).

Regards,

Ravi

Read only

0 Likes
1,495

Kumar,

If you have put Exclusive Lock for an entry with a SDNO say XXX using ENQUE function module, unless and untill you do DEQUE for the same XXX SDNO the database lock do not get released. And till this is DEQUEd no one else can make any change in that record. DEQUE happens either by using DEQUE function exclusively or if you log out from the SAP session all the lock entries get DEQUEd or released automatically.

The lock entries can be seen using Tcode SM12.

Read only

Former Member
0 Likes
1,495

So i have to pass the parameter SDNO in enquee , Dequee function Right ?

Read only

Former Member
0 Likes
1,496

So using ABAP report we do some Processing in TABLES , That time no uses will be able to do any update to Data base Table . Right ?

That Processing may be UPDATING DB table ?

Can you tell some Real Time Scenarios Where LOCK is Used ?

Which SAP Defined tables are used Frequently in LOCKING mechanism ?

This will solve my issue .

Read only

0 Likes
1,495

Kumar,

See the Lock Object 'EVVBAKE' created for VBAK i.e. SO header for the Sales Order No. Any person making any change in a SO (VA02) an lock entry gets created for that SO Number. So no one else make changes in the same unless and untill the lock is released.

Sample code to ENQUE the code for the same Lock Object

CALL FUNCTION 'ENQUEUE_EVVBAKE'

EXPORTING

vbeln = i_document_number

EXCEPTIONS

foreign_lock = 2

system_failure = 3.

Read only

Former Member
0 Likes
1,495

Thanks for Everyone . Closed The Thread