How-toSAP S/4HANAAPIs / PP, PM and MM

SAP PP, PM and MM API: Production Orders, Maintenance Orders and Material Master

Question
sap pp api

Also searched as

  • sap pm api
  • api sap pm
  • sap mm02 api
  • sap m table api

Short answer

S/4HANA exposes production orders, maintenance orders and material master through OData services published in the SAP Business Accelerator Hub, for example API_PRODUCTION_ORDER_2_SRV, API_MAINTENANCEORDER and API_PRODUCT_SRV. On ECC or older releases, use BAPIs and RFC such as BAPI_PRODORD_CREATE, BAPI_ALM_ORDER_MAINTAIN and BAPI_MATERIAL_SAVEDATA. Direct M-table access is not an API and is best avoided.

Applies to: SAP S/4HANA on-premise and private cloud (OData services activated in the Gateway). Public cloud exposes a subset through communication arrangements. ECC uses BAPIs and IDocs.

How to find and call the right API

  1. 1Search the SAP Business Accelerator Hub (api.sap.com) for the object: production order, maintenance order, product. Confirm the service is available for your release and edition.
  2. 2On-premise, activate the service in the Gateway with /IWFND/MAINT_SERVICE, add the system alias, and assign the service to the calling user's role.
  3. 3Test with /IWFND/GW_CLIENT before coding. A GET on the service root, then on the entity set with $top=1, proves access and the response shape.
  4. 4For reads, call the entity set with $select and $filter to keep the payload small, and page with $top and $skip.
  5. 5For writes, first GET with the header x-csrf-token: Fetch, then send the returned token on POST or PATCH with the same session cookie.
  6. 6For material master changes (the MM02 equivalent) use PATCH on the product entity in the Product service. Create goes through POST and is subject to the same validation as the dialog transaction.
  7. 7If no OData service covers the object, fall back to the released BAPI or a custom OData service on a CDS view, and keep authorisation in the CDS access control.
  8. 8Log every write and test in a sandbox client first. A material change can affect planning and costing immediately.

Common services by area

For production: API_PRODUCTION_ORDER_2_SRV covers production order headers, items, components and operations. For plant maintenance: API_MAINTENANCEORDER handles maintenance orders and API_MAINTNOTIFICATION handles notifications. For material master: API_PRODUCT_SRV is the A2X service for products, plants and valuation data.

Names and versions change between releases, so verify against the Hub for your version before building. Some objects, such as full routing maintenance, may only be available through BAPI or other interfaces.

GET /sap/opu/odata/sap/API_PRODUCT_SRV/A_Product?$top=5&$select=Product,ProductType,BaseUnit&$format=json
GET /sap/opu/odata/sap/API_PRODUCTION_ORDER_2_SRV/A_ProductionOrder_2?$top=5&$filter=Plant eq '1000'
GET /sap/opu/odata/sap/API_MAINTENANCEORDER/MaintenanceOrder?$top=5

BAPIs on ECC and older S/4

Where OData is not available, the long-standing BAPIs apply: BAPI_PRODORD_CREATE and BAPI_PRODORD_RELEASE for production orders, BAPI_ALM_ORDER_MAINTAIN and BAPI_ALM_NOTIF_CREATE for maintenance, and BAPI_MATERIAL_SAVEDATA for material master. They are called through RFC, SOAP via the Service Builder or a middleware, and need BAPI_TRANSACTION_COMMIT after a successful call.

The existing article on BAPI_TRANSACTION_COMMIT explains why a BAPI that returns success may still not save.

Why not read M tables directly

Tables such as MARA, MARC and MBEW look like an API, and the generic RFC_READ_TABLE function is often used as one. It truncates long rows, ignores authorisation objects unless you add checks, and is not supported for this use. In S/4HANA many reads now belong to CDS views and released APIs. Use a released OData service or a CDS-based service, so SAP's upgrade path and authorisations apply.

Security and throttling

Use a technical user with a narrow role, not a dialog user, and prefer OAuth or certificate authentication over basic authentication where your landscape allows it. Expect to throttle bulk reads: page through large entity sets and avoid running full extracts during planning runs.

Try it here, free

SAP PP Go-Live Master Data and Cutover Checklist

Open full tool

A tick-box readiness check for production planning go-live, covering master data, configuration, cutover and support.

Common pitfalls

  • !Calling a service that has not been activated in /IWFND/MAINT_SERVICE.
  • !Skipping the CSRF token fetch and getting 403 on POST or PATCH.
  • !Using RFC_READ_TABLE as a general API.
  • !Assuming OData names are identical across releases and public cloud.
  • !Forgetting to commit after a BAPI call.

How an ERP-grounded AI assistant handles this

These APIs are what an AI assistant reads when answering questions like what is the status of production order 1000234 or which maintenance orders are overdue. Netray's approach on SAP is read-only calls through released services with the caller's role, with the query shown and any write needing human approval. On-prem the model and the calls both stay inside your network.

Frequently asked questions

What API does SAP have for production orders?

In S/4HANA, API_PRODUCTION_ORDER_2_SRV exposes production orders through OData. On ECC and older systems use BAPIs such as BAPI_PRODORD_CREATE. Check the SAP Business Accelerator Hub for the version that matches your release.

Is there an API for MM02 material changes?

Yes. API_PRODUCT_SRV lets you read and change products with OData PATCH, and BAPI_MATERIAL_SAVEDATA covers the older route. Both apply the same validations as MM02, so test in a sandbox before bulk updates.

Can I call SAP M tables through an API?

Technically RFC_READ_TABLE can read them, but it is not meant for that, truncates rows and skips business authorisation. Prefer released OData services or CDS views so access follows the proper model.

Is there an SAP PM API?

Yes. API_MAINTENANCEORDER and API_MAINTNOTIFICATION cover maintenance orders and notifications in S/4HANA. On ECC use BAPI_ALM_ORDER_MAINTAIN and BAPI_ALM_NOTIF_CREATE. Confirm the exact service versions in the Hub for your release.

Related

How-to

How to Use BAPI_TRANSACTION_COMMIT Correctly

SAP's BAPI programming model separates business logic from the database commit on purpose, so a caller must explicitly call BAPI_TRANSACTION_COMMIT after a successful BAPI - usually with WAIT = 'X' - or the created object never actually persists. Skipping this step, or forgetting WAIT, is the most common reason a BAPI 'runs fine' but nothing gets saved.

How-to

SAP S/4HANA API Guide: Business Hub, OData, Public Cloud and Business Partner

S/4HANA APIs are discovered in the SAP Business Accelerator Hub and mostly delivered as A2X OData services such as API_BUSINESS_PARTNER. On-premise you activate them in the Gateway; in the public cloud you create a communication user, system and arrangement for a communication scenario. PI/PO or Integration Suite sit in between for orchestration, and SAP Digital Manufacturing has its own APIs on BTP.

How-to

Calling SAP APIs from Python: OData with requests, Authentication and PyRFC

The simplest way to call SAP from Python is OData over HTTPS with the requests library: send a GET to the service with $select, $filter and $top, authenticate with basic or OAuth, and follow the next-page link. For writes fetch a CSRF token first. Use PyRFC only for functions that have no OData service, and accept the extra SAP NW RFC SDK dependency.

Error fix

SAP M7 021: Deficit of SL Stock Quantity

M7 021 fires during a goods issue, delivery, or confirmation when SAP checks the unrestricted-use (SL) stock for the exact plant, storage location and batch combination and finds less than what you are trying to post out. Fix the entry (batch, storage location, quantity) first; only enable negative stock or downgrade the message to a warning if the business genuinely needs to post ahead of a receipt.

Error fix

SAP IDoc Status 51: Application Document Not Posted

Status 51 tells you the IDoc reached the application layer and failed to post, but the status text itself is not the error - the real cause sits in the status record's long text or the linked application log. Fix the underlying data or configuration, then reprocess the IDoc through BD87 rather than editing the status.

Error fix

SAP Short Dump TIME_OUT: Maximum Runtime Exceeded

A TIME_OUT runtime error means a dialog (or RFC) work process ran longer than the maximum allowed runtime, controlled by profile parameter rdisp/max_wprun_time (600 seconds by default). The fix is almost always to move the long-running work to background processing or tune the underlying program, not to raise the timeout.

AI for ERP

AI Agents for SAP Production Planning, MRP, and Exception Triage

AI agents that triage SAP MD04 exceptions, explain predictive MRP shortages, and draft planned-order actions, grounded on your own SAP data, deployed on-prem.

AI for ERP

AI for SAP Plant Maintenance: Notifications, Work Orders, and Predictive Signals

AI grounded on SAP PM data that triages notifications, drafts work orders, standardizes failure codes, and flags predictive maintenance signals, on-prem.

AI for ERP

AI for SAP S/4HANA, Running On-Prem or in Your Private Cloud

Run AI on SAP S/4HANA without sending ERP data to a public API. On-prem and private-cloud architecture, CDS views, OData, and honest deployment trade-offs.

Stuck on SAP S/4HANA?

Talk to engineers who work inside SAP S/4HANA every week, and who build private AI that answers these questions from your own ERP data.

Keep exploring

Free tools

ERP fixes and how-tos

Runs with your ERP

AI on your ERP

Integrations

Software