Symptom
When creating a Return delivery to vendor (movement type 122) via the Odata API_MATERIAL_DOCUMENT_SRV you are running into error message M7021 or error message M7328 and the posting fails.
Environment
SAP S/4HANA Cloud Public Edition
Reproducing the Issue
Post a 122 movement via API_MATERIAL_DOCUMENT_SRV
Cause
GR based IV case, missing the required reference fields in the payload.
If you have a regular Purchase Order Item with a stock material, you can post a 122 return via the API with reference to the Purchase Order.
If you have a regular Purchase Order Item with a stock material and with the 'GR Based IV flag' set, you can post a 122 return via the API but you must pass the assignment block reference as well as the Purchase Order.
Resolution
In the payload, pass the corresponding assignment block fields:
...
"InvtryMgmtReferenceDocument" : "xxxxxxxxxxx", (mseg-lfbnr)
"ReferenceDocumentFiscalYear" : "xxxx", (mseg-lfbja)
"InvtryMgmtRefDocumentItem" : "xxxx", (mseg-lfpos)
...
See Also
Keywords
M7021, M7328, VFBL, EKPO-WEMNG, MB_FILL_EKPO_ENQUEUE_TABLE, FM07MEM0_MENGE_PRUEFEN, MB_CHECK_MATERIAL_STOCKS, WEBRE, GR to vendor, 122, Deficit of PU GR quantity, API, A_MaterialDocumentHeader, 101, GoodsMovementCode, Reference to Material Document , KBA , MM-IM-GR-PO-2CL , Goods Receipt from External Procurement (Public Cloud) , MM-IM-GR-PO , Goods Receipt from External Procurement , Problem
SAP Knowledge Base Article - Public