Application Development 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: 

FM for locking

Former Member
0 Kudos
196

hi..

i have an equipment number eqnr .. i want to check that if any lock exists on tat eqnr..

can any one suggest me any FM tat will help me uot wid this..?

thnx.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
120

Please use ENQUEUE_EIEQUI

Regards,

RIch Heilman

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
121

Please use ENQUEUE_EIEQUI

Regards,

RIch Heilman

0 Kudos
120

hi..

ENQUEUE_EIEQUI

can u please explain if i want to check the lock for an equipment and if i find tat there exists a lock..then i have to wait for 2 sec and then chk it again ..if the lock still exists..

in this case the WAIT parameter if i pass WAIT = '5'.

will work..

thnx

0 Kudos
120

Simply call it like this. The WAIT parameter needs a value of "X". It will wait a predetermined amount of time for the lock to be released, You could do this in a loop if necessary, keep checking sy-subrc untill it = 0.




report zrich_0001.

parameters: p_equnr type equi-equnr.

start-of-selection.


  call function 'ENQUEUE_EIEQUI'
    exporting
      mode_equi            = 'E'
      mandt                = sy-mandt
      equnr                = p_equnr
*   X_EQUNR              = ' '
*   _SCOPE               = '2'
      _wait                = 'X'
*   _COLLECT             = ' '
    exceptions
      foreign_lock         = 1
      system_failure       = 2
      others               = 3.
  if sy-subrc <> 0.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.


Regards,

RIch Heilman

0 Kudos
120

hi..

wait = 'X' will for for how long can we define it ....?

and loop in the sence

can u give example for loop.. i m new to abap so i m not aware of this...

thnx..

0 Kudos
120

The wait parameter will wait as per a system wide setting setup by your basis people, I would imagine that it is not too long. One question, how long do you plan to wait untill you give up?

Regards,

RIch Heilman

0 Kudos
120

So in this example, I am doing a loop and check for a lock, if I don't get one, I wait for 5 seconds, this loop continues untill 30 seconds, no lock then it quits and gives message.




report zrich_0001.

data: counter type i.

parameters: p_equnr type equi-equnr.

start-of-selection.


  clear counter.

  do.

* Exhausted,  no luch in getting a lock, get of of DO loop.
    if counter > 6.
      sy-subrc = 1.
      exit.
    endif.

* Try for lock
    call function 'ENQUEUE_EIEQUI'
      exporting
        mode_equi            = 'E'
        mandt                = sy-mandt
        equnr                = p_equnr
*    _wait                = 'X'
      exceptions
        foreign_lock         = 1
        system_failure       = 2
        others               = 3.
* Got a lock, get out of DO loop. 
   if sy-subrc  = 0.
      exit.
    endif.

* Still here?  Then wait another 5 seconds
    wait up to 5 seconds.
    counter = counter  + 1.

  enddo.

* Report status
  case sy-subrc.
    when  0.
      message s001(00) with 'Lock could not be established'.
    when  1.
      message i001(00) with 'Lock could not be established'.
  endcase.

Regards,

Rich Heilman

Former Member
0 Kudos
120

Hi Neha,

Just go to SE37, type DEQUEUE* and hit F4. Provide additional parameters which would help you zero in on the appropriate FM. Use this FM to unlock your object. To lock your record, use ENQUEUE*..and find the appropriate FM.

Regards

Anil Madhavan

Former Member
0 Kudos
120

its urgent