‎2009 Nov 29 12:53 PM
Hi All ,
I use this locking (write lock) and i want to verify if i do it OK .
what i do is to check if the entry is locked if so try 5 times .
one more thing is that that i dont know how the parameter behavior and _wait can help me .
Regards
Chris
DO iv_try_x_times TIMES. "Try to lock object for 5 times before skiping the object
lv_count = lv_count + 1.
CALL FUNCTION 'ENQUEUE_E_D_USR'
EXPORTING
mandt = sy-mandt
userid = mv_userid
x_for_user = iv_is_exact " If FOR_USER is initial this defines the lock behavior
wait = ivis_wait
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
RETURN.
ENDIF.
IF lv_count < iv_try_x_times.
WAIT UP TO 1 SECONDS.
ENDIF.
ENDDO.
‎2009 Nov 29 1:01 PM
Hi Chris,
Code is fine. are you facing some issue with this??
Read this it will give you more clear picture:
http://help.sap.com/saphelp_nw70/helpdata/en/41/7af4c8a79e11d1950f0000e82de14a/content.htm
http://help.sap.com/saphelp_nw04/Helpdata/EN/af/22ab01dd0b11d1952000a0c929b3c3/content.htm
Edited by: Harsh Bhalla on Nov 29, 2009 6:38 PM
‎2009 Nov 29 2:42 PM
HI Harsh ,
Thanks ,
i read the help but i not sure that i understand the use of
x_for_user = iv_is_exact
_wait = iv_is_waitcan you please explain the need of the parametrs , one example is if i use the counter (in loop)
for what i need the wait ?
or what is the use of x_for_user and how it can help me ?
Regards
Chris
‎2009 Nov 29 3:03 PM
Hi Chris,
Read this to get clarification
http://help.sap.com/saphelp_nwpi71/helpdata/en/cf/21eebf446011d189700000e8322d00/content.htm
‎2009 Nov 29 9:21 PM
HI Harsh ,
thanks but i do some wait logic in the loop do i need to use also the parameter wait ?
Regards
Chris
‎2009 Nov 29 11:00 PM
Chris,
There is no clear documentation on the _WAIT parameter. However the short description of the data element DDENQWAIT says "Flag indicating whether lock attempt is to be repeated" (Values X and SPACE).
So my suggestion is you don't pass this parameter and leave it to its default value of SPACE and continue with your logic of attempting for a specified number of times before giving up.
The statement WAIT UP TO 1 SECONDS doesn't justify genuine assumption. Try to implement more elegant logic such as reading the database to check some value.
Regards,
Suresh
‎2009 Nov 30 3:06 AM
Hi,
somewhere I found documentation about WAIT parameter. I remember by default it will wait up to 3 seconds for a foreign lock being released. This is useful if - by chance - the object is locked by another process that does not need much time.
I always use the WAIT = 'X' because if the object is not locked it does not cost any time and if it is locked I may not have to repeat the whole process.
Regards,
Clemens
‎2009 Nov 30 9:20 AM
HI Clemens
thanks a lot
but do you suggest to use also the logic i did in the loop for 5 times with sytabix and in parallel use the wait .
one more thing is regard the x_for_user how can it help me ?
Regards
Chris
‎2009 Nov 30 2:30 PM
Hi Chris,
my personal thought is you should always try to gain simplicity. In this case it means: No need for the do-loop. And no need for the x_for_user parameter.
Regards,
Clemens