Skip to Content
avatar image
Former Member

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

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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

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

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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

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

    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.

    Add comment
    10|10000 characters needed 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