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 object not working.

Former Member
0 Likes
991

Hi,

I am trying to create a lock object.

Having following doubts:

1) In one program, ENQUEUE function for that lock object But DEQUEUE function is not called. So the record on which the ENQUEUE function is called will remain locked for ever or only till the program ends?

2) 1 program ZXYZ has ENQUEUE function on one record...But it has not DEQUEUE function in it....... second program ZXYZ1 is trying to edit that record....what should happen??

According to me, that second program should not be able to edit it until the table has given record to DEQUEUE function. Correct me if I am wrong.

But in these programs, Second program is able to edit the record locked by the first program. This is true if Lock Mode of the Lock object is Read Lock/Write Lock /Exclusive, Not cumulative.

Please let me know your valuable inputs.

Regards,

Pooja

10 REPLIES 10
Read only

jyotheswar_p2
Active Participant
0 Likes
951

Hi

That depends on the type of lock object whether you create excluusive or shared lock object.

If it is shared lock then they will be able to edit simultaniously.

Try changing the different type of locks.

Thanks & Regards

Jyo

Read only

0 Likes
951

Hi Jyotheswar,

I tried using all types of locks but Second program is able to edit the record.

I am not getting whats wrongu2026.

Regards,

Pooja

Read only

0 Likes
951

you have to modify both programs..

first call enqueue function and check sy-subrc.

if its 0 you can carry on with edit otherwise give a message that object is locked and exit.

Read only

0 Likes
951

Hi,

Try to put the break point just after the en queue function and one program reach at this point and then in other session run the second program and check the enque function for same entry and see whether it is allowing you change the same record by checking sy-subrc.

also check in SM12 transaction for locked entries.

Read only

0 Likes
951

Hi Pooja,

I have also faced the same problem.

But when we tried updating the table with differnent ways at the same time we didnt get any database issues.So we didnt make use of the lock object.It is still wowking fine.

Thanks & Regards

Jyo

Read only

0 Likes
951

Hi ,

Thanks for all your replies.

Please find below both the programs. SY-SUBRC is zero in both the programs.

Let me know if anything is wrong in the code. Commit work is not used anywhere in the program explicitly.

*First Program: *

REPORT ztestxyz.

TABLES: zcrossref.

DATA: wa_zcrossref TYPE zcrossref.

wa_zcrossref-business_unit = 'TOPS'.

wa_zcrossref-conversion_type = 'KS'.

wa_zcrossref-legacy_code = '0314'.

wa_zcrossref-sap_code = '0314'.

CALL FUNCTION 'ENQUEUE_EZTEST'

EXPORTING

mode_zcrossref = 'E'

client = sy-mandt

business_unit = wa_zcrossref-business_unit

conversion_type = wa_zcrossref-conversion_type

legacy_code = wa_zcrossref-legacy_code

x_business_unit = ' '

x_conversion_type = ' '

x_legacy_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.

ELSE.

WRITE: 'Sucessful.' .

UPDATE zcrossref FROM wa_zcrossref.

WAIT UP TO 20 SECONDS.

ENDIF..

Second program:

REPORT ztestxyz1.

*DATA: wa_loan TYPE zloandeposit.

*wa_loan-xblnr = 'FWD3939'.

*wa_loan-doctyp = 'AB'.

*MODIFY zloandeposit FROM wa_loan.

Data: wa_zcrossref type zcrossref.

wa_zcrossref-business_unit = 'TOPS'.

wa_zcrossref-conversion_type = 'KS'.

wa_zcrossref-legacy_code = '0314'.

wa_zcrossref-sap_code = 'XYZ2'.

UPDATE zcrossref FROM wa_zcrossref.

IF sy-subrc = 0.

WRITE: 'Succesful.!!'.

ELSE.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Regards,

Pooja

Read only

0 Likes
951

Hi,

It will be like trial and error method to check where the lock is getting unlocked.

Try putting breakpoint at update statement in your first program.

UPDATE zcrossref FROM wa_zcrossref.

Then, execute your second program. and check if you are able to lock the same object now. if no then go one more step further in 1st program, then again check if you are able to lock that object in 2nd program.

Just check this way. So, that you will get idea at what point lock is getting released.

Thanks,

Archana

Read only

Former Member
0 Likes
951

Hi,

1) In one program, ENQUEUE function for that lock object But DEQUEUE function is not called. So the record on which the ENQUEUE function is called will remain locked for ever or only till the program ends?
2) 1 program ZXYZ has ENQUEUE function on one record...But it has not DEQUEUE function in it....... second program ZXYZ1 is trying to edit that record....what should happen??

If anywhere in the code Commit is used, then it will automatically DEQUEUE the lock obects. Even if you have not exclusively used DEQUEUE in you program, commit statement will do that job here.

Thanks,

Archana

Read only

Former Member
0 Likes
951

Hi Pooja,

In second program also check for the lock object and update only when Lock is successful. You can also pass WAIT ='X' in case you want program to wait for sometime to acquire lock in case table is already locked.

Thanks,

Regards,

Mohaiyuddin

Read only

0 Likes
951

Hi,

Did you find the solution to your problem? I also have the same problem.

Thanks in advance.

Regards,

Joyie