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: 

Table locking by Lock Objects

Former Member
0 Kudos
344

Hello,

I have one custom table assume that ZXYZ. For this I have created lock objects with following details.

Lock type - E

Parameters - MANDT, PRUEFLOS, VBELN, AUFNR and some other fields.

Now we

do.

call function 'ENQUEUE_EZ_ZXYZ'

exporting

vbeln = ZXYZ

exceptions

foreign_lock = 1

system_failure = 2

others = 3.

CASE sy-subrc.

WHEN 0.

exit.

WHEN 1.

CONTINUE.

WHEN 2 or 3.

  • System failure. Contact with system administrator.

MESSAGE e089(zr).

ENDCASE.

enddo.

What is the significance of passing table name in the parameters of an object....But in fact there is no entry for that table name as vbeln. With this table is being locked one row. that can be seen in SM12.But what record it has locked.

Can you suggest me some thing ?

3 REPLIES 3

jayanthi_jayaraman
Active Contributor
0 Kudos
147

Hi,

Key field value you need to pass in the fm.Based on the key field,that particular record will be locked in the database.

Former Member
0 Kudos
147

hi,

the record u want to lock is to be sent as a parameter in vbeln.

santhosh

Former Member
0 Kudos
147

Hi Nagarjuna,

Probably you have done mistake while calling enqueue function module. The correct code will be look like the following.

do.
call function 'ENQUEUE_EZ_ZXYZ'
exporting
mode_zyz = 'E'
MANDT     = sy-mandt
PRUEFLOS =  <appropriate field>
VBELN  = <appropriate field>
AUFNR = <appropriate field>
exceptions
foreign_lock = 1
system_failure = 2
others = 3.
CASE sy-subrc.
WHEN 0.
exit.
WHEN 1.
CONTINUE.
WHEN 2 or 3.
* System failure. Contact with system administrator.
MESSAGE e089(zr).
ENDCASE.
enddo.

Generally all key fields should be considered as a parameters in lockobject. If you wantto add other fields, you can.

The main aim to taking parameters is to lock the entire record based on the combination value of all fields. So lockobject will never fail (since lockobject values are also store another database table - there entry is checking every time when new entry i.e. Primary key checking )

Plz observe the same thing in SM12 (putting break-point at SY-SUBRC ,you can see the entries how it is going to lock)

the lock value will combination of MANDT,PRUEFLOS,VBELN,AUFNR i.e. 100346370000001AU.

if helps reward points.

Regards

Bhupal Reddy