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

Regarding Function Module for Locking ( enque)

Former Member
0 Likes
906

Hi,

I am facing a Problem that is when iam running Call transaction one popup is coming because some other user currently editing that Tcode at that time i need to lock tcode using enque specially for table . If suppose some other user editing at that time it will shoe that popup and it will exit from their with out doing any other process For that i need Function module for Lock and Delock.

thanks in advance,

murali krishna.

3 REPLIES 3
Read only

Former Member
0 Likes
651

Please use ENQUEUE_EIEQUI

Regards,

rewards point

Read only

Former Member
0 Likes
651

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,

rewards point

Read only

Former Member
0 Likes
651

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,

rewards point