2013 May 16 1:39 PM
Hi
This is my first question on this portal.
We need to create a goods movement (code 501) whenever a goods movement code 261 is created, whether it's from transaction MIGO, MB1A or a custom program that generates them. So i used the BAdI MB_DOCUMENT_BADI - method MB_DOCUMENT_BEFORE_UPDATE to call a function i wrote to created the goods movement 501. This function calls BAPI_GOODSMVT_CREATE to do the busy work.
In testing, my goods movement creation code works great, but when it's called within the BADI, it fails and i get this message
Short text of error message:
Function module MB_CREATE_GOODS_MOVEMENT cannot be executed
Long text of error message:
Diagnosis
The function module MB_CREATE_GOODS_MOVEMENT is called up for the
second time. After it was called up the first time, the function
module MB_POST_GOODS_MOVEMENT was called, but a COMMIT WORK was not
carried out in the calling program.
As running the two function modules again would result in the
database being incorrectly updated, processing is terminated.
System Response Procedure Please ensure that a COMMIT WORK is set
after you call up the function module MB_POST_GOODS_MOVEMENT.
Technical information about the message:
Message class....... "M7"
Number.............. 299
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
From what i understand, i'm calling the function module MB_CREATE_GOODS_MOVEMENT within itself (before i can commit the BAPI) and SAP doesn't like that. Any idea how i can bypass that? Right now, it's done by a program that runs every hours that looks for the newly created material documents with the code 261 but the maintenance and warehouse teams need these to be instantaneous.
2013 May 17 1:24 PM
Hi
Call it with a job. Create this calling and encapsulate it in a function module with option IN UPDATE TASK. Call the BAPI from a report (with a selection screen), so, the sequence is:
JOB_OPEN
GET_PRINT_PARAMETERS
RS_CREATE_VARIANT "where you call this report
JOB_SUBMIT
JOB_CLOSE
And try in the same BADI but with method POST_DOCUMENT (you have the ID MBLNR and you can set it in any field and you can made some traceability for both documents)
I hope this helps you
Regards
Eduardo
2013 May 17 1:24 PM
Hi
Call it with a job. Create this calling and encapsulate it in a function module with option IN UPDATE TASK. Call the BAPI from a report (with a selection screen), so, the sequence is:
JOB_OPEN
GET_PRINT_PARAMETERS
RS_CREATE_VARIANT "where you call this report
JOB_SUBMIT
JOB_CLOSE
And try in the same BADI but with method POST_DOCUMENT (you have the ID MBLNR and you can set it in any field and you can made some traceability for both documents)
I hope this helps you
Regards
Eduardo
2013 May 17 8:50 PM
I pushed my code in a program and called it with a job defined in the BAdI and it works like a charm.
Thanks
3 weeks ago
Hi ,
I have the same requirement Could you please share sample code for below
JOB_OPEN
GET_PRINT_PARAMETERS
RS_CREATE_VARIANT "where you call this report
JOB_SUBMIT
JOB_CLOSE