11-21-2007 12:18 PM
Hi all,
I need to book an invoice while executing MIGO. I use the class MB_DOCUMENT_BADI and the method MB_DOCUMENT_UPDATE, where I call BAPI_INCOMINGINVOICE_CREATE. Unfortunately it does not work (it exits debugger), as it seems that the material document has not been created yet ( but inside the badi I have already MBLNR...) . I tried to use BAPI_TRANSACTION_COMMIT before creating invoice, but it also exits. Can use those BAPIs inside MB_DOCUMENT_UPDATE?
Thanks!
Anna
11-27-2007 2:48 AM
Hi,
when calling the BAPI call it in background task..
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
IN BACKGROUND TASK
...............
Thanks
Naren
11-27-2007 1:20 AM
Looks like the invoice creation fails because it tries to reference a material document that doesn't exist yet.
What you could try is to call BAPI_INCOMINGINVOICE_CREATE in a subroutine that is in a Z-program, and in method MB_DOCUMENT_UPDATE, you'd call that subroutine ON COMMIT. This would wait until your transaction does a COMMIT and only then it would execute the registered subroutine which then should be able to find the material document.
So, something like this:
Method MB_DOCUMENT_UPDATE.
Perform CALL_INVOICE_CREATE(ZPROG) Using <parameter list>
ON COMMIT.
Endmethod.
***
Program ZPROG.
Form CALL_INVOICE_CREATE Using <parameter list>.
Call Function BAPI_INCOMINGINVOICE_CREATE
EXPORTING...
IMPORTING...
Call Function BAPI_TRANSACTION_COMMIT.
Endform.
11-27-2007 2:48 AM
Hi,
when calling the BAPI call it in background task..
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
IN BACKGROUND TASK
...............
Thanks
Naren