‎2009 Oct 11 4:24 PM
HI All
i am want to handle lock object for instance if i want to lock some object and it's already locked i want to do some loop on it for 5 times .
1. i need to know if what i was doing is OK since this is my first time .
2. what should i use i parameter wait can it help me ?
Kind Regards
Chris
iv_try_x_times = 5. "this value on the method signature
DO iv_try_x_times TIMES.
lv_count = lv_count + 1.
CALL FUNCTION ENQUEUE_USR_DATA
EXPORTING
mandt = sy-mandt
userid = mv_userid
x_for_user = iv_is_exact
_wait = iv_is_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 Oct 12 12:26 PM
Hi Chris,
Such a code piece might help you;
data: is_locked type c,
lv_counter type i.
is_locked = ''.
lv_counter = 0.
while is_locked = '' and lv_counter < 5.
lv_counter = lv_counter + 1.
CALL FUNCTION ENQUEUE_USR_DATA
EXPORTING
mandt = sy-mandt
userid = mv_userid
x_for_user = iv_is_exact
_wait = iv_is_wait
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
is_locked = 'X'.
else.
wait up to 1 seconds.
endif.
endwhile.
Regards;
Ozcan.
‎2009 Oct 11 5:35 PM
Hi Chris....
Is it that you have to wait for 5 seconds and for each second you have to check lock once?
Or you have to check 5 times and terminate(no time constraint)?
Your code will work for 1st point above...
If the requirement is as 2nd point, remove the "WAIT UPTO 1 SECONDS"....
Guess you have the requirement as second point...
Regards,
Veeranji Reddy P.
Edited by: Veeranji Reddy on Oct 11, 2009 10:05 PM
‎2009 Oct 12 8:18 AM
Hi ,
I want to do the lock loop for 5 times if table is locked ,
and wait for one sec for it ?
Regards
Chris
Edited by: Chris Teb on Oct 12, 2009 11:38 AM
Edited by: Chris Teb on Oct 12, 2009 12:42 PM
‎2009 Oct 12 12:26 PM
Hi Chris,
Such a code piece might help you;
data: is_locked type c,
lv_counter type i.
is_locked = ''.
lv_counter = 0.
while is_locked = '' and lv_counter < 5.
lv_counter = lv_counter + 1.
CALL FUNCTION ENQUEUE_USR_DATA
EXPORTING
mandt = sy-mandt
userid = mv_userid
x_for_user = iv_is_exact
_wait = iv_is_wait
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
is_locked = 'X'.
else.
wait up to 1 seconds.
endif.
endwhile.
Regards;
Ozcan.