1.6 ERP-MES Contract: Orders, confirmations, consumption, scrap, WIP
The interface between ERP (Enterprise Resource Planning) and MES (Manufacturing Execution System) is not merely a data pipe; it is a binding contract between Finance and Operations. If the ERP believes you have 100 units of raw material, but the MES has physically consumed 105, your Balance Sheet is fiction. Design this interface to be transactional, idempotent, and resilient to network partitions.
The Architecture of Trust
Do not tightly couple these systems. ERP is the "Architect" (Planning); MES is the "Builder" (Execution).
- ERP Responsibility: Defines What to build, When to build it, and How Many (Demand).
- MES Responsibility: Enforces How it is built and reports Actuals (Execution).
Synchronization Logic
- If Master Data (BOM/Route) does not exist in MES → Then Reject Work Order (WO) immediately. (Never accept an order for a ghost product).
- If ERP sends a "Force Close" on a WO → Then MES must finish the active unit at the Quality Gate before terminating the run.
Message Contracts: The Data Handshake
Define strict schemas for every transaction. Ambiguous fields lead to inventory drift.
Downstream: Work Order Management (ERP → MES)
Work Order Create
- 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 status).
Work Order Change
- Trigger: Qty increase/decrease or Date shift.
- Logic:
- If New_Qty < Qty_Produced → Reject Update. (You cannot un-make physical products).
- If Status = "Running" → Notify Supervisor to acknowledge the change.
Work Order Close
- Trigger: Short-close or cancellation.
- Action: MES releases reserved material allocations back to General Inventory.
Upstream: Execution Feedback (MES → ERP)
Material Issue (Consumption)
- Trigger: Component mounted 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.
Production Completion (Good Receipts)
- 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.
Non-Conformance & Scrap
- Trigger: Unit fails and cannot be reworked.
- Payload: WO_ID, Component_Part, Reason_Code, Cost_Center.
- Impact: Triggers financial write-off. Pro-Tip: Map MES "Defect Codes" (technical) to ERP "Reason Codes" (financial) in a lookup table.
Genealogy / As-Built Record
- Trigger: WO Close.
- Payload: Do not send the full trace tree to ERP (it cannot handle the volume). Send a Summary Link (URL) or a PDF reference to the compliance record stored in the MES/Historian.
Error Strategy & Resilience
Networks fail. APIs timeout. Design for failure to prevent data loss.
Idempotency Keys
Every transactional message must carry a unique Transaction_UUID.
- Scenario: MES sends "Consumption: 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 |
Integrity | 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 must reject consumption if Stock < 0 (Configurable) |
Errors | DLQ Monitoring | Alert if DLQ depth > 10 messages |
Drift | Reconciliation | Auto-report variances > 1% daily |
Genealogy | Storage | ERP holds the Link; MES holds the Tree |