04-09-2008 7:48 PM
Hi,
I am attempting to read user locks programmatically by calling the function: ENQUEUE_READ. This however is not working. Has anyone successful read locks using this FM?
Piece from my function module
checking to see if user has a BPS BSP layout lock
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = sy-mandt
gname = 'UPC_YS_LOCK'
guname = sy-uname
IMPORTING
number = l_num
TABLES
enq = l_enq.
Thank you!
~ Lisa
04-09-2008 9:01 PM
SImply pass client and that's it ...
'UPC_YS_LOCK' is table name on which locks exist..if any entry of this table is not being edited currently..then it will not return anything...
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = leave blank if you want locks across the system
gname = table name which is locked/leave blank
guname = leaveblank
IMPORTING
number = l_num
TABLES
enq = l_enq.
If you want to see it work then simply pass the table name you see in sm12..
04-09-2008 8:41 PM
How did you know it's not working?? Is it giving any exception..check sy-subrc value and post back!!
04-09-2008 8:49 PM
I checked SM12 to ensure I had locks, called ENQUEUE_READ and parameter: l_num returned 0. (I had 2 locks)
After I check the locks, I need to be able to log those user out if they in fact have locks...
log user off if lock exists
IF l_num > 0.
CALL FUNCTION 'TH_DELETE_USER'
EXPORTING
user = sy-uname
client = sy-mandt.
ENDIF.
Perhaps I'm using the wrong elementary ock (UPC_YS_LOCK)?
04-09-2008 8:51 PM
Hi Lisa,
Your code looks perfect. I think it is an authorization issue. Check you have proper authorization to execute that Function Module as this is related to Security.
Thanks,
Greetson
04-09-2008 8:54 PM
Will do! I'll let you know whether I don't have the proper authorizations or not...
~ Lisa
04-09-2008 9:01 PM
SImply pass client and that's it ...
'UPC_YS_LOCK' is table name on which locks exist..if any entry of this table is not being edited currently..then it will not return anything...
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = leave blank if you want locks across the system
gname = table name which is locked/leave blank
guname = leaveblank
IMPORTING
number = l_num
TABLES
enq = l_enq.
If you want to see it work then simply pass the table name you see in sm12..
04-09-2008 9:09 PM
I ran the function without the table name and l_num was populated!
It makes sense that the table would only be populated with a lock if entries were being edited.
Thanks for your help guys!
~ Lisa Gravito
04-09-2008 9:12 PM
04-09-2008 9:17 PM
Sorry! 1st time posting. Please let me know if I've now rewarded the points correctly.
Edited by: Lisa Gravito on Apr 9, 2008 3:18 PM
04-09-2008 9:20 PM