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

locking issue

Former Member
0 Likes
911

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.

8 REPLIES 8
Read only

Former Member
0 Likes
880

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

Read only

0 Likes
880

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_wait

can 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

Read only

Read only

0 Likes
880

HI Harsh ,

thanks but i do some wait logic in the loop do i need to use also the parameter wait ?

Regards

Chris

Read only

0 Likes
880

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

Read only

0 Likes
880

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

Read only

0 Likes
880

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

Read only

0 Likes
880

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