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

Cannot use BAPI_GOODSMVT_CREATE in MB_DOCUMENT_BEFORE_UPDATE

Former Member
0 Likes
1,103

Hi experts,

I need to do enhance to post additional 313 movement after post 962 movement.

I picked up MB_DOCUMENT_BEFORE_UPDATE to be triggered after press save button and used BAPI_GOODSMVT_CREATE to post 313.

The problem is BAPI_GOODSMVT_CREATE returned error 'Enter Plant'!.

All parameters were already tested with SE37 and it worked great.

I did a lot debugging and found that all MSEG data were mysteriously cleared after it run 'PERFORM fusszeile_wa_pruefen(sapmm07m) USING x.' in source code SAPLMBWL.

After that, I tried a new way. I submitted my Z program ,which call BAPI_GOODSMVT_CREATE with exactly same parameter, in BADI and it returned error that material ... batch ... is already locked.

I'm not sure that is it possible to post additional material document in this BADI(MB_DOCUMENT_BEFORE_UPDATE).

Best regards,

Amornpon

6 REPLIES 6
Read only

Former Member
0 Likes
910

r u using COMMIT WORK or BAPI_TRANSACTION_COMMIT? i guess, u know that, its not supposed to use COMMIT WORK and BAPI_TRANSACTION_COMMIT in badis, inperspective of data integration, data guarantee!!!

So, try to build a custom FM (instaed of SUBMITting ur Z report) and call it with addition of NEW TASK in ur badi .

thanq

Read only

0 Likes
910

Thanks for reply.

I did create FM and called it in BADI but it gave the same result as I called BAPI directly from enhance program.

and what do you mean 'NEW TASK' Is that you mean call function in update task?

I did try call function in update task but it didn't work.

The problem is BAPI function returned that Mat XXX Batch XXX is alreay locked by XXX and also cannot get created material doc number.

Read only

0 Likes
910

Before executing BAPI its good Idea to check if that data is already Locked for editing or so, so that BAPI does not error out. As far as your problem with BAPI is concerned you will be able to solve them after proper analysis. I could sense the problem in code.

Regards

Shital

Read only

Former Member
0 Likes
910

I think that I get the problem wrong.

The problem actually causes by MB11. When I entered material ,batch, sloc, qty ,the MB11 will lock this batch for material I entered. That is why I cannot do any MIGO related to this batch.

I think that I cannot post additional MIGO in MB_DOCUMENT_BEFORE_UPDATE anyway but is there any way that I will be able to post 313 after MB11 unlocks this batch?

Read only

Former Member
0 Likes
910

I will use batch session. It will work for sure but it needs manual action.

Thanks

Read only

Former Member
0 Likes
910

Hi,

An alternate way to achive a solution to your problem is to trigger a workflow after you do the first posting.

When the first posting is done, the workflow event will be triggered.

In this workflow you can write the code for the 2nd posting.

Regards,

Ankur Parab