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: 

Goods movement Locked

Former Member
0 Kudos
250

Hi all,

I wrote a program in ABAP to post 2 goods movement. First, the program post a 101 goods movement, then a Z39 goods movement.

After the program finished the 101 goods movement, while attempting to post the Z39 goods movement, it encounter error like below:

"The program is locked by User ****".

The program locked the user itself while try to post Z39 Goods movement.

I was wondering if some one can help me with this issue. Thanks

Regards,

Andy Chan

7 REPLIES 7

suresh_datti
Active Contributor
0 Kudos
121

try putting a COMMIT WORK statement between the two postings..

~Suresh

0 Kudos
121

Hi Suresh,

Thanks for your reply. But I already put a Commit Work in between. I even put a WAIT command in between to slow down the transaction.

Regards,

Andy Chan

0 Kudos
121

This is not a good way of programming but try

WAIT FOR 30 SECONDS.

The problem in your case is the earlier GM is still working and the lock is held by this process thus giving you that error.

hith

Sunil Achyut

Looks like you have already tried this, try increasing the seconds to may be 120-200 seconds, just to see if it works.

Message was edited by: Sunil Achyut

Former Member
0 Kudos
121

Hi Sunil Achyut,

Thanks for your reply. Actually, I already tried out with the WAIT command. And It solved with every waiting of 5 seconds. I put the WAIT command in between the 2 movements and after the Z39 movements.

But I am seeking for a better solution because the program eventually will load a list of records (maybe up to 1000++). If every record have to wait for at least 10 seconds, eventually the program will takes quite a long time to finish the transaction.

So, I was wondering if there any better solution for this.

Thanks.

Regards,

Andy Chan

0 Kudos
121

You can try this.. put the code that pertains to the Z39 Movement type in a custom function module & call it as a Separate Unit of Work using the following option:

CALL FUNCTION func ...STARTING NEW TASK task name.

~Suresh

Message was edited by: Suresh Datti

0 Kudos
121

Can you try the following logic:

1) After your first update, check for the lock using the enqueue FM.

2) If locked wait for say 5 seconds and check again. If its not locked then continue with your normal processing.

Since its a continuous posting of movements, I would also be interested gaining knowledge from others in the forum for the same.

hith

Sunil Achyut

0 Kudos
121

I had a similar problem that I solved by putting in a WAIT statement. But a better solution (proposed by Rich) is to enqueue with _WAIT = 'X':


  CALL FUNCTION 'ENQUEUE_EIQMEL'
    EXPORTING
      qmnum          = zzfservice_order-qmnum
      <b>_wait          = 'X'</b>
    EXCEPTIONS
      foreign_lock   = 1
      system_failure = 2
      OTHERS         = 3.

It will wait til the other lock is released and can lock it again. Then just remove the lock.

Rob