Skip to Content
0

BAPI_GOODSMVT_CREATE doesn't post material document inside loop inspite of COMMIT

May 26, 2017 at 01:19 PM

272

avatar image
Former Member

Hi All,

Help needed!

I've been facing this strange problem for sometime. I'm using BAPI_GOODSMVT_CREATE to post a stock transfer from plant to plant during creation of Sales Order. Now, a line item in Sales Order might have unrestricted stock in multiple batches( txn. MMBE). So, I will have to call the BAPI multiple times to post multiple batches. Eventually, I'm calling this BAPI inside a loop. Now, the real problem is, it posts the material document on the first iteration of the loop. It doesn't post on subsequent loops. So, my goods movement is done from only one batch. I added a BAPI_TRANSACTION_COMMIT after the call, still it doesn't post after the first iteration. This happens in random sales orders. Not everytime.

Thank You!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member May 26, 2017 at 01:57 PM
1

Did you look at the return parameter of the BAPI_GOODSMVT_CREATE? When calling the BAPI inside a loop, you could encounter issue that the material/plant locks created by previous call may not have release yet. You could try putting a wait of 3 sec after commit statement to prevent this. Or could try commit only outside the loop.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for the response Sireesh. I thought of doing this. But, do you think adding a 3 second WAIT might have an impact on the performance? Also, I did try this earlier in another program, as a 5 second pause and it only works when i debug the program. It doesn't when the program is run on the fly or if it is part of a transaction. The moment I save the Sales Order, I'm able to see the record in the table the next second.

Thanks,

Harish M

0

You might want to read the answer again - the first suggestion was to look at the return table of the BAPI. Are you doing that and when the document does not get posted don't you see any messages in the table?

Before taking an action you need to establish the root cause first. Otherwise you could be solving a non-existent problem.

Also post the actual code when asking such questions.

0
Former Member

Dear Sirish/Jelena,

I agree with your points. I do have a check at the return table level after the BAPI is called. I push a BAPI_TRANSACTION_COMMIT only if the BAPIRET is initial and the return parameter of GOODSMVT_HEADRET has a value in field MAT_DOC.

Thanks,

Harish M

0
avatar image
Former Member May 26, 2017 at 03:20 PM
0

Harish,

Please check and report on the return parameter of the BAPI. Since this is not happening in debug, you might want to use Message or write statement.

Based on how you are describing, if this is working in Debug and not otherwise, it could most likely be a Lock issue at the material/plant level. Just for testing purpose, you could introduce a 5 sec wait after commit. It will definitely effect the performance.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Dear Sireesh,

Thanks for the input. I will do and try it for sure. But, as this happens in random scenarios i might need a while to test this properly.

Thanks again!

Regards,

Harish M

0