Fetch the X-CSRF-Token via GET /sap/opu/odata/sap/API_PHYSICAL_INVENTORY_DOC_SRV/?sap-client=100 with header 'X-CSRF-Token: Fetch'; store the returned token and session cookie.
Create the physical inventory document: POST .../PhysInventoryDocHeader with a JSON body containing FiscalYear, Plant, StorageLocation, and PhysInventoryDocDesc; the response returns the PhysicalInventoryDocument and FiscalYear key.
Add items to the document: POST .../PhysInventoryDocItem with PhysicalInventoryDocument, FiscalYear, Material, Plant, StorageLocation, and BookQtyInEntryUnit (system book quantity).
Enter count results by sending PATCH to the item entity with QuantityInEntryUnit set to the physical count value and IsQuantityConfirmed = true; this marks the count as entered.
Post inventory differences by calling the PostDifferences function import: POST .../PostDifferences with PhysicalInventoryDocument and FiscalYear in the body — this triggers material document creation for all lines with a variance between book and counted quantity.
Verify the posted material document number returned in the function import response and check it in SAP transaction MI07 (Post Inventory Differences) for audit compliance.
Known gotchas
The PostDifferences function import posts differences for the entire document at once; if any single item line has a blocking error (e.g., material is blocked for posting), the entire document posting fails — validate all items before calling PostDifferences.
Physical inventory documents in SAP have a fiscal-year scope; a document created in one fiscal year cannot have items added or counts posted against it in a subsequent fiscal year — always use the current open fiscal year when creating documents via API.
API_PHYSICAL_INVENTORY_DOC_SRV is an OData v2 service; the entity set names use SAP's proprietary OData extension annotations — always retrieve the $metadata document from the live system to confirm entity set names rather than relying on documentation screenshots.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp