1.6 ERP-MES Contract: Orders, confirmations, consumption, scrap, WIP
The interface between ERP (Enterprise Resource Planning) and MES (Manufacturing Execution System) is thenot financialmerely a data pipe; it is a binding contract between Finance and operationalOperations. equatorIf the ERP believes you have 100 units of raw material, but the factory.MES Ifhas physically consumed 105, your Balance Sheet is fiction. Design this datainterface contractto fails,be transactional, idempotent, and resilient to network partitions.
The Architecture of Trust
Do not tightly couple these systems. ERP is the company either ships products it cannot bill or builds products it does not need. Define this integration with strict transactional logic, not vague synchronization promises.
Production Orders"Architect" (Planning); MES is the "Builder" (Execution).
- ERP
→Responsibility: MES)
The ERP dictatesDefines whatWhat to build, When to build it, and when.How The MES executes how. Do not allow the MES to create production orders autonomously; it must remain a slave to the ERP planning engine.
Download Triggers
Trigger:ManyOrder Status change to "Released" in ERP.(Demand).Frequency:MES Responsibility:Real-timeEnforces How it is built and reports Actuals (Webhook) or near real-time (Polling ≤ 15 mins)Execution).
Validation Logic
Upon receiving an order, the MES must perform a "Sanity Check" before accepting it.
IfSKU does not exist in MES Master Data →Reject Order + Alert Planning.IfRequired BOM components are obsolete/blocked →Hold Order.IfOrder Qty > 0 AND Due Date ≥ Today →Accept & Schedule.
Pro-Tip: Never update an active order's quantity in the ERP while it is running in the MES. Instead, close the original order and issue a new "Child Order" for the delta. This preserves traceability.
Confirmations & WIP Updates (MES → ERP)
The MES must report progress back to the ERP to keep financial accounts accurate. Balance the granularity of reporting against system load.
Reporting Granularity
Milestone Reporting:Report only at key financial gateways (e.g., SMT Complete, Box Build Complete, Shipping).Step-by-Step Reporting:Report every barcode scan.Decision:UseMilestone Reporting. Step-by-step floods the ERP with noise and creates locking issues during high-volume production.
ConfirmationSynchronization Logic
- If
OperationMaster= "Critical Gateway"Data (e.g.,BOM/Route)EnddoesofnotLine)exist in MES →TriggerThenERPRejectConfirmationWork Order (WO) immediately. (Never accept an order for a ghost product). - If ERP
APIsendsisadown"Force Close" on a WO →QueueThenMessageMESlocallymust(Store & Forward). Never stopfinish thelineactivebecauseunitSAPatisthepatching.Quality Gate before terminating the run.
MaterialMessage ConsumptionContracts: (BackflushThe vs.Data Discrete)Handshake
InventoryDefine accuracystrict dependsschemas onfor whenevery andtransaction. howAmbiguous youfields deductlead components.to inventory drift.
StrategyDownstream: A:Work BackflushingOrder Management (Standard)ERP → MES)
DeductWork componentsOrder automaticallyCreate
- Trigger: Planner releases order in ERP.
- Payload: WO_ID, Part_Number, Revision, Qty_Target, Scheduled_Start, Priority.
- Constraint: The WO_ID must be globally unique. If WO_ID exists, treat as an idempotent update (or reject based on
thestatus).
Work whenOrder the parent assembly is confirmed.Change
Use Case:Trigger:HighQtyvolume,increase/decreaseloworcostDatecomponents (Resistors, Screws).shift.Risk:Implicitly assumes 100% yield. If you scrap a unit but don't record it, inventory drifts.
Strategy B: Discrete Issue (Real-Time)
Deduct components exactly when scanned/loaded onto the machine.
Use Case:High value, serialized components (CPU, PCBA, Displays).Control:Logic:- If
MaterialNew_Qtyis<"Class A" (High Value)Qty_Produced →RequireRejectDiscreteUpdate.Issue(You cannot un-make physical products). - If
MaterialStatusis= "Bulk"Running" →SetNotify Supervisor toBackflush.acknowledge the change.
- If
Scrap & Non-Conformance
Scrap is money on fire. The digital system must record the burn immediately to trigger replacement orders and financial write-offs.
ScrapWork WorkflowsOrder Close
Material Scrap:Trigger:ComponentShort-closedamagedorduring assembly.cancellation.- Action:
OperatorMESselectsreleasesreasonreservedcodematerialonallocationsHMIback to General Inventory. - Trigger:
movementComponenttomounted or batch consumed. - Payload: WO_ID, Component_Part, Lot_Number, Qty_Consumed, UoM.
- Strategy: Use Micro-Batching (e.g., every 15 mins or every 50 units). Real-time 1:1 transaction reporting often creates "Row Locking" issues in the ERP database.
- Trigger: Unit passes Final Quality Gate.
- Payload: WO_ID, Parent_Part, Serial_Number, Qty_Good, Location_ID.
- Impact: Increases Finished Goods (FG) inventory in ERP.
Assembly Scrap:Trigger:Entire unitUnit fails and cannot berepaired.reworked.Action:Payload:SupervisorWO_ID,authorizesComponent_Part,scrapReason_Code,→ MES consumes all child parts → MES closes specific serial number as "Scrapped" → ERP reduces Production Order open quantity.Cost_Center.
Upstream: Execution Feedback (MES → MESERP)
Material Issue to(Consumption)
Production Completion (Good Receipts)
Non-Conformance & Scrap
Triggers financial write-off. Pro-Tip: Map every MES defect"Defect codeCodes" (technical) to ERP "Reason Codes" (financial) in a specificlookup GLtable.
Genealogy / As-Built Record
- Trigger: WO Close.
- Payload: Do not send the full trace tree to ERP (
GeneralitLedger)cannotaccounthandle the volume). Send a Summary Link (URL) or a PDF reference to the compliance record stored in theERP.MES/Historian.
Error Fault"Strategy goes& Resilience
Networks fail. APIs timeout. Design for failure to prevent data loss.
Idempotency Keys
Every transactional message must carry a differentunique accountTransaction_UUID.
- Scenario: MES sends "
OperatorConsumption:Error.50 units". Network times out. MES retries. - Without Idempotency: ERP deducts 100 units.
- With Idempotency: ERP sees the same UUID, ignores the second payload, and returns "Success (Cached)".
The Dead-Letter Queue (DLQ)
Never discard a failed message. If a message fails validation (e.g., "Part Number Not Found"):
- Move message to DLQ.
- Alert IT Support.
- Hold dependent transactions (preserve sequence).
- Retry mechanism (Exponential Backoff: 30s, 1m, 5m, 1h).
Reconciliation Jobs (The Safety Net)
Running solely on event triggers is risky. Implement a "State of the Union" sync.
- Frequency: Nightly (during low load).
- Logic: Compare ERP.WIP_Balance vs MES.WIP_Balance.
- If Variance > Threshold → Create Adjustment Journal and flag for audit.
Final Checklist
Category | Metric / Control | Threshold / Rule |
| Idempotency | All APIs require Transaction_UUID header |
Performance | Batching | Material Consumption micro-batched (5–15 min) |
Logic | Validations | Block "Create WO" if Master Data is missing |
Inventory | Negative Stock | ERP |
|
| Alert if DLQ depth > 10 messages |
Drift | Reconciliation | Auto-report variances > 1% daily |
Genealogy | Storage | ERP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|