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

Former Member
0 Likes
507

Hi SDN's

I created a a lock object for a Z table, so that when the user tries to access the same record from a Z Tcode.

it is getting locked fine, and geting unlocked also ...

but what i want to know is how do i know the user name who has locked it?

can i know it from the function modules ENQUEUE or DEQUEUE or is there any other way where i can know the User Name who has locked it?

Regards

Pratyusha

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
476

I believe this will come automatically if you have the exceptions uncommented and the IF statement after the ENQUEUE function call uncommented.

 

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

Regards,

RIch Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
477

I believe this will come automatically if you have the exceptions uncommented and the IF statement after the ENQUEUE function call uncommented.

 

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

Regards,

RIch Heilman

Read only

0 Likes
476

Hi Rich, Yes it is as what u said. But i gave a msg of my own saying 'Record Locked'

but now when i uncommented it, i dont get any msg, where as i can open the same in 2 diff sessions.

Please check my part of code

  • Lock the transaction if the same MO is being changed else

loop at IT_RFQITEM into IS_RFQITEM.

call function 'ENQUEUE_EZ_ENQUE_RFQ'

exporting

  • MODE_ZES_RFQ_ITEM = 'E'

MANDT = SY-MANDT

RFQ_NO = IS_RFQITEM-RFQ_NO

SER_NO = 1

RFQ_LN = IS_RFQITEM-RFQ_LN

  • X_RFQ_NO = ' '

  • X_SER_NO = ' '

  • X_RFQ_LN = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

exceptions

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

others = 3.

if SY-SUBRC <> 0.

  • message E138(ZSM) with 'MO is locked'.

endif.

clear : IS_RFQITEM.

endloop.

Regards

Pratyusha

Read only

0 Likes
476

This is working fine for me.



....
 EXCEPTIONS
   FOREIGN_LOCK         = 1
   SYSTEM_FAILURE       = 2
   OTHERS               = 3
          .
IF sy-subrc <> 0.
  message e001(00) with sy-msgv1 ' is locking record'.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Regards,

Rich Heilman

Read only

0 Likes
476

Thanks Rich, its working fine

i did a silly mistake..

Thanks

Pratyusha