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 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)
...
Note: In Cloud release CE2008 the API does not fully support the GR Based IV processing, these reference fields are not available until CE2011
See Also
Keywords
M7021, 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 , KBA , MM-IM-GR-PO , Goods Receipt from External Procurement , MM-IM-GR-PO-2CL , Goods Receipt from External Procurement (Public Cloud) , Problem