sap-mm-procurement

Create and query SAP S/4HANA purchase requisitions, orders, and goods receipts via OData with LINE approval.

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/wusheyi/SAP_MM_SKILLS --skill sap-mm-procurement-wusheyi
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sap-mm-procurement
Source: https://github.com/wusheyi/SAP_MM_SKILLS/tree/main/skills/sap-mm-procurement
Command: npx skills add https://github.com/wusheyi/SAP_MM_SKILLS --skill sap-mm-procurement-wusheyi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It lets operators create and query SAP S/4HANA MM documents (purchase requisitions, purchase orders, goods receipts) directly through OData API calls with curl, while enforcing a LINE-based supervisor approval step before any PR or PO is actually posted to SAP. ## Core Features & Use Cases - Direct SAP OData Integration: Builds and sends payloads to API_PURCHASEREQ_PROCESS_SRV, API_PURCHASEORDER_PROCESS_SRV, and API_MATERIAL_DOCUMENT_SRV using curl with CSRF token and cookie handling, no local API server required. - LINE Approval Workflow: Routes PR and PO requests to the correct supervisor based on a job-level approval matrix and amount thresholds, persisting pending/approved/rejected state files before posting to SAP. - Query Support: Retrieves the latest purchase requisition items and specific purchase order items via GET requests. - Use Case: An operator types in LINE "create a PR for MAT_020, quantity 3, plant 1710, supplier A100, delivery 2026-06-20"; the skill builds the payload, sends the supervisor an approval message, and only posts to SAP after the supervisor replies with the approval command. ## Quick Start Ask the assistant to use the sap-mm-procurement skill to create a purchase requisition for a material with quantity, plant, supplier, and delivery date, after setting the SAP_ODATA_BASE_URL, SAP_USER, and SAP_PASSWORD environment variables.

Frequently Asked Questions about sap-mm-procurement

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a purchase requisition in SAP S/4HANA via OData?

POST a JSON payload to the A_PurchaseRequisitionHeader entity set of API_PURCHASEREQ_PROCESS_SRV after fetching a CSRF token and session cookies. The payload includes header fields plus a to_PurchaseReqnItem results array with material, quantity, plant, and delivery date in /Date(milliseconds)/ format.

How does the LINE approval workflow for purchase orders work?

Before posting a PR or PO, the skill looks up the requester in an approval matrix, walks the manager chain to find an approver meeting the required job level, and saves a pending state file. SAP is only called after the designated approver replies with the approval command and approval ID in LINE.

What environment variables are required for SAP OData calls?

You need SAP_ODATA_BASE_URL pointing to the /sap/opu/odata/sap root, SAP_USER, and SAP_PASSWORD. Optional variables include SAP_LANGUAGE (default ZF), SAP_VERIFY_SSL, SAP_APPROVAL_MATRIX_FILE, and SAP_APPROVAL_STATE_DIR for approval state storage.

Can I post a goods receipt without supervisor approval?

Yes, goods receipts via API_MATERIAL_DOCUMENT_SRV can be posted directly when the user explicitly asks, using GoodsMovementType 101 and GoodsMovementCode 01. The approval workflow is mandatory only for PR and PO creation, though GR can reuse it if required.

Why does my SAP OData POST fail with a CSRF error?

SAP requires fetching an X-CSRF-Token first with a GET request using the header X-CSRF-Token: Fetch while storing cookies. You must then send that token and the same cookie jar with the POST request, or SAP rejects the write operation.

What date format does SAP OData V2 expect in payloads?

SAP OData V2 uses the /Date(milliseconds)/ format with Unix epoch milliseconds in UTC. Convert a date like 2026-06-20 in Linux with date -u -d "2026-06-20 00:00:00" +%s and append 000 for milliseconds.