1. BUSINESS REQURMENT
Goods movement cancellation through IDOC or custom program for Subcontracting PO scenario (movement type 101 and 543 which is including component materials). In this above business scenario goods movement cancellation through IDOC for 101 movement type along with 543 movement type, IDOC has been failed and status is 51 and the status message is “PU WITHRAWN QTY EXCEEDED by 543 movement type line item Qty: WITH Material no Plant and Batch no”.
But same material document has successfully cancelled and it creates the new material document with movement type 102 and 544, during the manual process in MIGO transaction.
When Sub-contracting PO scenario goods movement for material document cancelation in MIGO transaction (Manual process), it cancels the Material document and creates the new material document for 102 and 544.
Cancelled Material Document
We are able to cancel the material document if we use the transaction MIGO, however If we cancel the goods movement through other transactions / IDOC then the Function Module “BAPI_GOODSMVT_CANCEL’ is called and cancels the goods movement. But in the IDOC call Function Module has return the exception “PU WITHRAWN QTY EXCEEDED by 543 movement type line item with Qty: Material no Plant and Batch no”.
4. SOLUTION PROPOSED
Reverse Goods Movements with Function module “BAPI_GOODSMVT_CANCEL” which calls one more Function module ‘MB_SET_BAPI_FLAG’ is used to Set flag XBAPI for BAPI_GOODSMVT_CANCEL. If MIGO transaction is used then the Function module ‘MB_SET_BAPI_FLAG’ Global parameter XMIGO = ‘X’ else the XMIGO variable value is SPACE other than MIGO.
Create Enhancement in Function Module ‘MB_SET_BAPI_FLAG’ to check the IDOC message type from memory.
ASSIGN ‘(RBDMANI2)T_EDIDC-MESTYP’ TO <LFS_MESTYP>.
If the message type <LFS_MESTYP> is a valid message type or SY-REPID = Z*, then set the parameter XMIGO = “X”.
Then It cancels the material documents like MIGO if it is Z-program or through IDOC.
5. Related SAP Modules
SAP-MM and SCM
IDOC ‘BAPI_GOODSMVT_CANCEL’ has been triggered in Middleware to cancel the Material Document.
Cancelled Material Document
7. TEST RESULT
Step 1: Before creating the enhancement, If the IDOC has executed then the flag in Function module ‘MB_SET_BAPI_FLAG’ Global parameter XMIGO = space, and the IDOC status is 51 and the status message is “PU WITHRAWN QTY EXCEEDED by 543 movement type line item Qty: Material no Plant and Batch no”. And the Material document hasnot cancelled.
Step 2: After creating the enhancement, set the flag in Function module ‘MB_SET_BAPI_FLAG’ Global parameter XMIGO = ‘X’, the IDOC successfully posted and the IDOC status has 53.
And Material document created successfully for Movement type 102 and 544.