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

Help in lock object

Former Member
0 Likes
529

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

1 ACCEPTED SOLUTION
Read only

former_member848108
Active Participant
0 Likes
487

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.

3 REPLIES 3
Read only

Former Member
0 Likes
487

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

Read only

0 Likes
487

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

Read only

former_member848108
Active Participant
0 Likes
488

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.