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

calling multiple times BAPI_GOODSMVT_CREATE getting error

Former Member
0 Likes
1,090

I am calling multiple times BAPI_GOODSMVT_CREATE for same Purchase order to post goods receipt.

first goods receipt created successfully but second one has given the error the Purchase order is lockecd by USER 'XXXX' .

i am calling 'BAPI_TRANSACTION_COMMIT after each BAPI BAPI_GOODSMVT_CREATE.

i tried with passing parameter WAIT = 'X' in 'BAPI_TRANSACTION_COMMIT. then also getting same error message.

please any one tell me the solution

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
808

Why are you calling it multiple times for the same purchase order?

Regards,

Rich Heilman

Read only

0 Likes
808

Try DEQUEUEing after the commit. Here is a sample coding.



* Call goods movement BAPI
call function 'BAPI_GOODSMVT_CREATE'
     exporting
          goodsmvt_header  = gm_header
          goodsmvt_code    = gm_code
     importing
          goodsmvt_headret = gm_headret
          materialdocument = gm_retmtd
     tables
          goodsmvt_item    = gm_item
          return           = gm_return.

if not gm_retmtd is initial.
<b>  commit work and wait.
  call function 'DEQUEUE_ALL'.</b>
  write:/ gm_retmtd.
else.
  commit work and wait.
  call function 'DEQUEUE_ALL'.
endif.


Regards,

Rich Heilman

Read only

0 Likes
808

Or you can just keep adding the receipts to the gm_item tab and process the BAPI once for each po number.

That works to.

Regards,

Rich Heilman

Read only

0 Likes
808

thanks for your reply

we have requirement partial goods receipts for purchase orders diffrent times.

so i need to call each time BAPI_GOODS_MVT_CREATE for each parial goods receipt.

i will try with call function 'DEQUEUE_ALL'.

please can you expalain what is the use of WAIT parameter in 'BAPI_TRANSACATION_COMMIT'.

Thanks

Read only

0 Likes
808

Use wait for 5 seconds.

Read only

sridhar_k1
Active Contributor
0 Likes
808

You get the error because locks in the update work process are not released yet when you call the bapi second time.

You can try adding SET UPDATE TASK LOCAL before calling the bapi.

Regards

Sridhar