2012 Feb 02 12:49 PM
Hi
I am selecting some records based on some selection criteria and acquiring a lock on them by ENQUEUE. After processing the records, I call DEQUEUE. My problem is when I call DEQUEUE, some locks are being released and some are not. For those whose lock is not released, I have to call the DEQUEUE function again.
I have tried debugging but am not able to figure out anything.
Any help would be appreciated. I would be glad to furnish more information as and when required.
Thanks,
Varun
Hi
I am selecting some records based on some selection criteria and acquiring a lock on them by ENQUEUE. After processing the records, I call DEQUEUE. My problem is when I call DEQUEUE, some locks are being released and some are not. For those whose lock is not released, I have to call the DEQUEUE function again.
I have tried debugging but am not able to figure out anything.
Any help would be appreciated. I would be glad to furnish more information as and when required.
Thanks,
Varun
2012 Feb 02 6:25 PM
Try function module DEQUEUE_ALL and see if it releases those locks.
This may not be an option if you can't release all locks of an LUW though.
Just curious: if you call DEQUEUE again for those keys that were not released, do they release with the second call?
2012 Feb 03 5:25 AM
Hi Tamas
I would not like to use DEQUEUE_ALL because it will release even the locks I dont want to release.
and a second call to DEQUEUE for the keys that were not released, releases them
Thanks,
Varun
2012 Feb 03 4:34 AM
Hello Varun,
I would be glad to furnish more information as and when required.
You could start with posting code snippet on how you are locking and unlocking the records?
Are you sure the parameters passed to the ENQUEUE & DEQUEUE modules identify each record uniquely?
BR,
Suhas
2012 Feb 03 5:12 AM
Hi Suhas
The locking is being done by the following code:
LOOP AT lit_tsw_subnode_asgns ASSIGNING <lwa_tsw_subnode_asgns>.
CALL FUNCTION 'ENQUEUE_/CASTP/EVALASGN'
EXPORTING
mode_/castp/t_valasgn = /castp/if_cas_constants=>gc_lock_exclusive
mandt = sy-mandt
tsw_guid = <lwa_tsw_subnode_asgns>-tsw_guid
tsw_location = <lwa_tsw_subnode_asgns>-tsw_location
transport_mode = <lwa_tsw_subnode_asgns>-transport_mode
x_tsw_guid = ' '
x_tsw_location = ' '
x_transport_mode = ' '
_scope = '2'
_wait = ' '
_collect = ' '
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
ENDLOOP.
Each record is being identified uniquely by the parameters passed to ENQUEUE and DEQUEUE
The unlocking is done as follows:
LOOP AT lit_tsw_subnode_asgns_all
INTO lwa_tsw_subnode_asgns.
CALL FUNCTION 'DEQUEUE_/CASTP/EVALASGN'
EXPORTING
mode_/castp/t_valasgn = /castp/if_cas_constants=>gc_lock_exclusive
mandt = sy-mandt
tsw_guid = lwa_tsw_subnode_asgns-tsw_guid
tsw_location = lwa_tsw_subnode_asgns-tsw_location
transport_mode = lwa_tsw_subnode_asgns-transport_mode
x_tsw_guid = ' '
x_tsw_location = ' '
x_transport_mode = ' '
_scope = '2'
_synchron = ' '
_collect = ' '.
ENDLOOP.
The entries in the sm12 transaction:
After ENQUEUE:
03.02.2012 Dynamic List Display 1
Client User name Time...... Lock mode Table name Lock Argument Use Count. Use Count.
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 3006E09844C8ED8BD5AE10000000A4287F7CBOT 01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFA4999AB0209A8BECC RIVER RD01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFA4999AB020F98CD3CIN KELLOG01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFAB84BC7575B9CF1FBL BURG 01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFAB88D2EA0BC589CBBL BURG 05 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFAB88D2EA0C875581CIN KELLOG05 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFAB88D2EA0D648F45CBOT 05 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFACFEF944EB8E15E8GR OHIO 01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFAD81C846AA718D73GR OHIO 01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFA4999AB020368259BL BURG 01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFA4999AB02154C96BCIR VILLE 01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFA4999AB021C04745LIMA 01 0 4
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFAB88D2EA0B2D0F03GR OHIO 05 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFAB88D2EA0C298A4AC RIVER RD05 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFAB88D2EA0D01C9AFCIR VILLE 05 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 300E8AF874CD31F4727E10000000A4287F7CBOT 01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 300################################LIMA 05 0 2
Selected Lock Entries: 17BR
Varun
Edited by: Varun Saravagi on Feb 3, 2012 6:21 AM
2012 Feb 03 5:23 AM
Hi Suhas
In continuation of previous message:
After DEQUEUE
03.02.2012 Dynamic List Display 1
Client User name Time...... Lock mode Table name Lock Argument Use Count. Use Count.
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 3006E09844C8ED8BD5AE10000000A4287F7CBOT 01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFA4999AB0209A8BECC RIVER RD01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFA4999AB020F98CD3CIN KELLOG01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DDFAB84BC7575B9CF1FBL BURG 01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFA4999AB020368259BL BURG 01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFA4999AB02154C96BCIR VILLE 01 0 1
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 30080215ADEE5481DEFA4999AB021C04745LIMA 01 0 2
300 SARAVAGI 06:04:05 E /CASTP/T_VALASGN 300E8AF874CD31F4727E10000000A4287F7CBOT 01 0 1
Selected Lock Entries: 8The parameters passed to ENQUEUE and DEQUEUE identify each record uniquely.
BR,
Varun
2012 Feb 03 6:27 AM
Hello Varun,
I think you're getting this mismatch because the records in lit_tsw_subnode_asgns & lit_tsw_subnode_asgns_all are different! Please check & confirm.
Please note that the lock will be released when the LUW ends!
BR,
Suhas
2012 Feb 03 6:42 AM
Hi Suhas
The records are same in lit_tsw_subnode_asgns & lit_tsw_subnode_asgns_all . I have double checked them. Only the name of the table have been changed.
Does it have anything to do with the Use Counter of the lock entries? If you will see the sm12 entries, the ones with use counter = 1 are released in the DEQUEUE but those with use counter > 1 have their counter decremented on DEQUEUE and are released on another call to DEQUEUE.
Thanks,
Varun
2012 Feb 03 7:25 AM
Does it have anything to do with the Use Counter of the lock entries? If you will see the sm12 entries, the ones with use counter = 1 are released in the DEQUEUE but those with use counter > 1 have their counter decremented on DEQUEUE and are released on another call to DEQUEUE.
Nice observation Varun. F1 on this field tells us that counter > 1, means cumulation of lock entries & the lock on these entries will be released once the cumulation counter reaches 0.
I can see that you have use lock mode as E(xclusive), which allows records to be locked more than once in the same transaction.
If you want to avoid this scenario you can use the lock mode X (eXclusive non-cumulative).
Also check the param _SCOPE, imo this is a very important param which is often neglected!
Edited by: Suhas Saha on Feb 3, 2012 12:58 PM
Please note that the lock will be released when the LUW ends!
Let me take this opportunity to correct myself
Actually the locks are released when the transaction ends and not at the end of the LUW. So basically COMMIT WORK(AND WAIT) wont release the locks!
BR,
Suhas
PS: You can refer to the SAP online documentation on [Cumulation of Locks|http://help.sap.com/saphelp_nw04/helpdata/en/37/a2e3a8344411d3acb00000e83539c3/content.htm] for further details
2012 Feb 03 6:15 AM
Hi,
are you doing the commit work after ENQUEUE [loop and end loop], if so in order to avoid DEQUEUE [some locks are being released and some are not.]
use " commit work and wait " this statement i hope will solve your the problem.
2012 Feb 03 6:20 AM
Hi $SAPGURU$
I am using COMMIT WORK AND WAIT only.
Thanks,
Varun
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |