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 practically consumed 105, your Balance Sheet is fiction. This interface must be designed to be transactional, idempotent, and resilient to network partitions.
The architecture of trust
Section titled “The architecture of trust”These systems must not be tightly coupled. 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
Section titled “Synchronization logic”- When the required Master Data (like a BOM or Routing) is missing from the MES, the system should reject the Work Order (WO). Producing a generic product without complete definition introduces risk and inaccuracies.
- When the ERP sends a “Force Close” command on an active Work Order, the MES should allow the currently active unit to gracefully finish its operation at the Quality Gate before terminating the run.
Message contracts: the data handshake
Section titled “Message contracts: the data handshake”Strict schemas must be defined for every transaction. Ambiguous fields lead to inventory drift.
Downstream: work order management (ERP → MES)
Section titled “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: A requested increase or decrease in quantity, or a shift in the delivery date.
- Logic:
- When the newly requested quantity is less than the quantity already produced, the system must reject the update. Tracking requires accurate accounting of physical products already built.
- When the Work Order status is currently “Running” on the floor, the system should notify the Supervisor to review and manage the change gracefully without disrupting the line.
Work Order Close
- Trigger: Short-close or cancellation.
- Action: MES releases reserved material allocations back to General Inventory.
Upstream: execution feedback (MES → ERP)
Section titled “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: Micro-Batching must be used (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.
Genealogy / As-Built Record
- Trigger: WO Close.
- Payload: The full trace tree must not be sent to ERP (it cannot handle the volume). A Summary Link (URL) or a PDF reference to the compliance record stored in the MES/Historian must be sent.
Error strategy & resilience
Section titled “Error strategy & resilience”Networks fail. APIs timeout. Systems must be designed for failure to prevent data loss.
Idempotency keys
Section titled “Idempotency keys”Every transactional message must carry a unique Transaction_UUID.
- Scenario: The MES transmits a “Consumption: 50 units” message. A network timeout occurs, and the MES retries the transmission.
- Without Idempotency: The ERP might process both messages and deduct 100 units.
- With Idempotency: The ERP detects the duplicate UUID, ignores the second payload, and simply returns a “Success (Cached)” response.
The dead-letter queue (DLQ)
Section titled “The dead-letter queue (DLQ)”Messages are important records and should not be discarded, even when they fail. When a message fails validation (for example, “Part Number Not Found”):
- The message must be moved to the DLQ.
- The IT Support team must be alerted.
- Any dependent transactions must be held to preserve the sequence of events.
- A Retry mechanism must be initiated using an Exponential Backoff strategy (e.g. 30s, 1m, 5m, 1h).
Reconciliation jobs (the safety net)
Section titled “Reconciliation jobs (the safety net)”Running solely on event triggers is risky. A “State of the Union” sync must be implemented.
- Frequency: Nightly (scheduled during periods of low system load).
- Logic: The system compares the WIP balance in the ERP against the physical WIP balance recorded in the MES.
- Action: When the variance exceeds the defined threshold, the system should automatically create an Adjustment Journal and flag the discrepancy for an audit.
Recap: ERP-MES Transaction Processing Rules
Section titled “Recap: ERP-MES Transaction Processing Rules”| Parameter | Requirement | Action / Logic | Condition / Constraint |
|---|---|---|---|
| Work Order (WO) Creation | WO_ID must be globally unique. | Treat duplicate WO_ID as idempotent update or reject based on status. | Payload: WO_ID, Part_Number, Revision, Qty_Target, Scheduled_Start, Priority. |
| Work Order Change | Quantity change requested. | Reject update if new quantity < quantity already produced. Notify Supervisor if WO status is “Running”. | Prevents inaccurate accounting of physical products. |
| Material Consumption | Report component consumption. | Use micro-batching (e.g., every 15 min or 50 units). | Payload: WO_ID, Component_Part, Lot_Number, Qty_Consumed, UoM. |
| Non-Conformance & Scrap | Report failed unit. | Map MES Defect Code to ERP Reason Code via lookup table. | Payload: WO_ID, Component_Part, Reason_Code, Cost_Center. Triggers financial write-off. |
| Genealogy Record | Report traceability on WO Close. | Send summary link/PDF reference, not full trace tree. | Record stored in MES/Historian. |
| Transaction Idempotency | Prevent duplicate processing. | Every message must carry a unique Transaction_UUID. | ERP ignores duplicate UUID, returns “Success (Cached)”. |
| Message Failure | Handle validation/transmission failure. | Move message to Dead-Letter Queue (DLQ), alert IT, hold dependent transactions, retry with exponential backoff. | Preserves sequence and prevents data loss. |
| WIP Reconciliation | Sync ERP and MES balances. | Nightly job compares balances. Create Adjustment Journal if variance exceeds threshold. | Scheduled during low system load. |