‎2008 Apr 03 12:31 PM
Hi,
I have created a lock object for one of my tables ZTAB1.
I have also incorporated the following ENQUEUE codes into my report program:
MODULE enqueue INPUT.
OK_CODE = SY-UCOMM.
CASE ok_code.
WHEN 'ENQUEUE'.
CALL FUNCTION 'ENQUEUE_EZTAB1'
EXPORTING
MODE_ZKKA301 = 'E'
LOAD_ID = ZTAB1-LOAD_ID
RECORD_ID = ZTAB1-RECORD_ID
DP_NUMC2 = ZTAB1-DP_NUMC2
X_LOAD_ID = ' '
X_RECORD_ID = ' '
X_DP_NUMC2 = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
.
CASE sy-subrc.
WHEN 0.
MESSAGE i888(ztry) WITH 'Enqueue successful'.
WHEN 1.
text = sy-msgv1.
MESSAGE e888(ztry) WITH 'Record already'
'locked by' text.
CALL TRANSACTION 'SM12'.
WHEN 2 OR 3.
MESSAGE e888(ztry) WITH 'Error in enqueue!'.
ENDCASE.
WHEN 'DEQUEUE'.
CALL FUNCTION 'DEQUEUE_EZTAB1'
EXPORTING
MODE_ZKKA301 = 'E'
LOAD_ID = ZTAB1-LOAD_ID
RECORD_ID = ZTAB1-RECORD_ID
DP_NUMC2 = ZTAB1-DP_NUMC2
X_LOAD_ID = ' '
X_RECORD_ID = ' '
X_DP_NUMC2 = ' '
_SCOPE = '3'
_SYNCHRON = ' '
_COLLECT = ' '
.
CASE sy-subrc.
WHEN 0.
MESSAGE i888(ztry) WITH 'Dequeue successful'.
WHEN 1.
MESSAGE e888(ztry) WITH 'Error in dequeue!'.
ENDCASE.
WHEN 'SM12'.
CALL TRANSACTION 'SM12'.
ENDCASE.
ENDMODULE.
How do I know my ENQUEUE code works? In other words, how do I know the record has been locked and no write is possible until the DEQUEUE code is run? Thanks.
‎2008 Apr 03 12:38 PM
use transaction sm12.
it will show all your (and other users) locks placed.
so just debug upto just past your enqueue call and check with sm12.
‎2008 Apr 03 1:02 PM
Hi,
Put a break point inside Enqueue function module and run it.
When controller comes to break point,try using Enqueue function module in another program.If it throws an eror then ur Enquue is working fine.
Thanks
--Pradeep
‎2008 Apr 03 1:10 PM
Hi,
Durinf Execution of Enqueue FM, If you get an exception , it means that object os locked by another user.
Thanks,
Rajani.
‎2008 Apr 03 2:18 PM
Hi,
I have tested my program, and it showed that when I run one instance of my program with the ENQUEUE function, I can't run another instance of the same program with ENQUEUE.
However, I can run ANOTHER program to update that same record that was locked (or, I can use SE16 to update the locked record). Is this the expected behaviour after I perform ENQUEUE?
‎2008 Apr 03 2:38 PM
hI,
During the time u are performing ENQUEUE operation on a set of data then it is not posible to update same set of data in SE16.
In your program you have locked some set of data and if u try to update other set of data it is possible.
Regards
Sandipan
‎2008 Apr 03 3:08 PM
For my example above, I was trying to lock a particular record in ZTAB1 using ENQUEUE:
LOAD_ID = '100001', RECORD_ID = 1,
DP_NUMC2 = 1 (note: LOAD_ID, RECORD_ID and DP_NUMC2 are primary keys)
When I run the ENQUEUE function in my program, I get an error message when I try to run the ENQUEUE function in another instance of the program again. However, I can actually edit the record (LOAD_ID = '100001', RECORD_ID = 1,
DP_NUMC2 = 1) using SE16.
By right, I shouldn't be able to (since the record is locked), right? Is it because I didn't create the lock object correctly? Or, is there some other reason?
‎2008 Apr 03 3:17 PM
Hi,
According to your scenario when u have locked a record using ENQUEUE u cant change it unless u DEQUEUE it before.
I think there is some problem in the lock object itself.
Are the data u r editing getting saved/changed when u have locked the data?
Check your Lock Mode?
Regards
Sandipan
‎2008 Apr 03 3:13 PM
Hi,
Please refer the link below:
http://www.sapdev.co.uk/dictionary/lock_enqueue.htm
Thanks,
Sriram Ponna.
‎2008 Apr 03 3:31 PM
Ok, maybe I'll further explain my scenario here.
ZTAB1 has 4 columns:
LOAD_ID (Primary Key)
RECORD_ID (PK)
DP_NUMC2 (PK)
DP_NUMC4
I have two records in ZTAB1:
LOAD_ID RECORD_ID DP_NUMC2 DP_NUMC4
100001, 1 1 20
100001, 1 2 23
I created a lock object for ZTAB1 using SE11. I then implemented the corresponding ENQUEUE FM in my report.
In my report, I have a button that runs the ENQUEUE FM to lock the first record upon clicking:
CALL FUNCTION 'ENQUEUE_EZTAB1'
EXPORTING
MODE_ZKKA301 = 'E'
LOAD_ID = '100001'
RECORD_ID = 1
DP_NUMC2 = 1
.
So, I clicked on the button, and the ENQUEUE is performed successfully (SY-SUBRC = 0). At this point in time, the first record should be locked. But when I go to SE16 and try to change the DP_NUMC4 of the first record, I was able to do so!
Why is that? How do I check the lock mode?
‎2008 Apr 05 1:27 PM
Hello,
I've already done the same problem. My analysis is :
- SE16 is not calling the enqueue function MODULE of the Ztable,
- your specific program is calling the enqueue function module of the Ztable.
==> you can update a record with SE16 despite a z-report is locking the record.
You can create a report that is updating a record without calling the enqueue module.
You can try to update a record using SM30 instead SE16 (sm30, i think locks entries)/
Cordialement,
Chaouki.
‎2008 Apr 05 2:37 PM
hi,
Use Tcode, SM12 to find the lock entries.
Thanks,
Vaishnavi