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

Dequeue not working in one call

Former Member
0 Likes
7,983

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

10 REPLIES 10
Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
4,043

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?

Read only

0 Likes
4,043

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
4,043

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

Read only

Former Member
0 Likes
4,043

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:	       17

BR

Varun

Edited by: Varun Saravagi on Feb 3, 2012 6:21 AM

Read only

Former Member
0 Likes
4,043

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:	       8

The parameters passed to ENQUEUE and DEQUEUE identify each record uniquely.

BR,

Varun

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
4,043

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

Read only

Former Member
0 Likes
4,043

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
4,043

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

Read only

Former Member
0 Likes
4,043

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.

Read only

0 Likes
4,043

Hi $SAPGURU$

I am using COMMIT WORK AND WAIT only.

Thanks,

Varun