The same work order shows as “open” in the ERP and “completed” in the MES; the warehouse count doesn’t match; both teams say the problem is on the other side. That is the picture when the MES–ERP link is set up badly. This link brings the production plan down to the shop floor and carries what happens on the shop floor back to the stock, costing and shipping systems. Below, within the ISA-95 (IEC 62264) framework, we cover the data objects between levels 3 and 4, the responsibility boundary, integration methods and the shortcomings in error handling that lead to duplicate stock postings in the field. If data leaving the MES is also to be connected to order or commercial business applications, define the scope of ERP and API integration separately.
The ISA-95 functional hierarchy and the level 3–4 boundary
In the ISA-95 functional hierarchy, level 4 is business planning and logistics: production planning, material requirements planning, purchasing, stock valuation, costing. The time scale is days, weeks and months. Level 3 is manufacturing operations management: dispatching work orders to lines, detailed scheduling, material tracking, quality recording, production performance. The time scale is shifts, hours and minutes. Level 2 and below are control systems.
The real question of integration is “whose information is this?”. The practical benefit of ISA-95 is that it makes clear at which level each piece of information is produced and at which level it is consumed. A common split:
| Details | Owner (source) | Consumer |
|---|---|---|
| Material master data, bill of materials | ERP (level 4) | MES |
| Routing / operations, standard times | ERP or PLM | MES |
| Work order and quantity | ERP | MES |
| Detailed sequencing, machine assignment | MES (level 3) | Shop floor, operator |
| Actual production, consumption, scrap | MES | ERP |
| Lot / serial traceability detail | MES | ERP (summary), quality |
The table can vary from plant to plant. What should not vary is that the decision is made in writing and a single source is defined for each piece of information. Every place where two systems can change the same field comes back a few months later as a reconciliation record. For the standard’s framework, ISA’s ISA-95 page is the starting point.
Core data objects between levels
ISA-95 Part 2 defines the information exchanged between levels 3 and 4 with object models. The ones used most often in projects:
- Product definition: How the product is made; bill of materials, operations, required resources.
- Production schedule (operations schedule): Requests coming from the ERP saying how much is to be produced and by when; in practice, work orders.
- Production performance (operations performance): Actual production, material consumed, scrap generated, time spent.
- Material, personnel and equipment information: Lots, storage locations, competencies, capacity.
- Production capability: Which resource is available when.
In process industries, the recipe (formula) is handled separately. The general recipe lives in the ERP or PLM, and the site-specific control recipe at levels 2–3. Don’t expect the ERP to manage PLC parameters directly; when this boundary is crossed, an ERP update becomes able to change a machine setting on the shop floor.
Integration methods: B2MML, API and staging tables
There are three common ways of moving data between levels 3 and 4. Most projects use more than one together. None of the methods (message queue, API or staging table) prevents duplicate stock postings on its own; the record ID that identifies duplicates and the reconciliation between the two systems are designed separately.
| Method | Strength | Limitation |
|---|---|---|
| B2MML (XML messages) | One-to-one with ISA-95 objects, field definitions ready-made | The schema is broad; both sides need support |
| REST / SOAP API | Real-time, with clear validation and error responses | Needs a queue when the other side is down |
| Staging table | Simple, traceable, decouples the two sides in time | Requires state management and housekeeping discipline |
| Message queue / broker | Loose coupling, built-in retries | Requires additional infrastructure and monitoring |
B2MML is the implementation published by MESA that defines ISA-95 objects with XML schemas. Messages consist of a verb and a noun; ISA-95 Part 5 (IEC 62264-5) defines verbs such as GET/SHOW, PROCESS/ACKNOWLEDGE, CHANGE/RESPOND, CANCEL and SYNC. For example, a list of work orders is transferred with the PROCESS or SYNC verb, and receipt is confirmed with ACKNOWLEDGE. Message and element names have changed between B2MML versions (V7 uses names such as OperationsSchedule and is not fully backward compatible with V6); compare against the documentation of the schema version you use. Ready-made field definitions cut off the “which field holds the quantity unit” argument between two teams from the start.
In the API approach, the ERP or MES calls the other side’s web service. Error responses are immediate. But if there is no persistent queue on the sending side while the other side is unreachable, data is lost. This is a common gap.
In the staging table approach, one side writes records to a shared database table, and the other side reads them and updates the status field. It is simple and easy to debug; many ERPs’ ready-made interfaces also follow this model. A minimal schema could be as follows (SQL Server syntax; data types must be adapted for other databases):
CREATE TABLE mes_production_confirmation (
confirmation_id BIGINT NOT NULL PRIMARY KEY,
work_order_no VARCHAR(20) NOT NULL,
operation_no VARCHAR(10) NOT NULL,
material_no VARCHAR(40) NOT NULL,
lot_no VARCHAR(40) NULL,
good_qty DECIMAL(18,3) NOT NULL,
scrap_qty DECIMAL(18,3) NOT NULL,
unit VARCHAR(5) NOT NULL,
created_at DATETIME2 NOT NULL, -- UTC
status CHAR(1) NOT NULL DEFAULT 'N', -- N:new P:processing D:done E:error
error_message NVARCHAR(500) NULL,
retry_count INT NOT NULL DEFAULT 0,
processed_at DATETIME2 NULL
);
confirmation_id is generated on the MES side and is unique; the ERP must not process a record arriving a second time with the same ID as a new confirmation. This is the most important rule of the integration. We come back to it below.
Example work order and production confirmation flow
- Release: Planning releases the work order in the ERP. The ERP sends the work order number, material, quantity, due date, bill of materials and routing to the MES.
- Acceptance: The MES validates the order (are the material and routing defined in the MES, are the units compatible?) and returns an accept or reject response. The reason for rejection must be visible in the ERP; if it isn’t, the order waits silently.
- Scheduling: The MES assigns the order to lines and machines and sequences it. This information is usually not sent back to the ERP; if it is, only the planned start and end times are sent.
- Production and consumption: When production starts on the shop floor, the MES records actual quantities, consumed material lots and scrap.
- Confirmation: At the defined frequency (end of lot, pallet, shift or operation), the MES passes the production and consumption confirmation to the ERP. The ERP creates goods receipt and goods issue documents.
- Closure: When the operation or work order is complete, the MES sends a closure confirmation; the ERP performs technical completion and costing.
The signals needed to enrich the same flow with OEE and downtime data are described in the article the right data sources for OEE calculation.
Master data ownership and synchronisation
Most integration problems come not from transaction data but from master data. If a material code does not exist in the MES, the work order is rejected. If unit conversion differs, stock drifts slowly and is only noticed at the stock count. Rules:
- Changes to materials, bills of materials and routings are transferred from the ERP to the MES on an event basis or at least daily.
- The bill of materials and routing are tied to the work order as a version. A master data change made after the order has been opened must not silently change the open order.
- Units and conversion factors are defined in one place; if the MES has a separate unit table, its synchronisation is monitored.
- MES-specific data (machine parameters, operator competencies, control plan details) stays in the MES and is not moved to the ERP.
In architectures where shop floor signals and MES objects are published in a common namespace, the ISA-95 equipment hierarchy is also reflected in the topic structure; this design is covered in the article Unified Namespace (UNS) architecture.
Error handling and retries
There will be integration errors. The point is that errors are not lost and that retries do not duplicate data. The typical cause of a duplicate goods receipt is a retry after a timeout without an ID check.
- Idempotency: Every message must have a unique ID generated on the sending side; if the receiver has already processed this ID, it must return the result again and not create a new document. Otherwise, a retry after a timeout produces a duplicate stock posting.
- Order: Confirmations belonging to the same work order must be processed in sequence. If the closure confirmation is processed before the last production confirmation, the ERP may reject the late production confirmation on the grounds that the order is closed.
- Persistent queue: If an API is used, the sending side should first write the message to its own database and then send it (the outbox pattern). The message is not lost even if the application restarts.
- Separating permanent from transient errors: Network or timeout errors are retried automatically; business errors such as “material not found” are not retried but reported to a person. A service that retries the same business error thousands of times overnight fills the log disk.
- Visibility: There should be a monitoring screen for failed and pending records, and an alarm when a threshold is exceeded. Correcting and resending a failed record must be logged. At regular intervals, the confirmations sent by the MES and the documents created by the ERP should be compared by record ID (reconciliation), and the list of differences passed to the person responsible.
Design checklist
- The owning system and consuming system have been defined in writing for every information object.
- The work order, bill of materials and routing version are transferred together; open orders are not affected by master data changes.
- Every message has a unique ID; the receiving side does not create a new document for a repeated message.
- Messages belonging to the same work order are processed in sequence.
- Transient and permanent errors are separated; permanent errors are reported to a person responsible.
- How many hours the MES can produce while the ERP is unreachable is known and has been tested.
- Time fields are in UTC; the quantity unit is carried explicitly in every message.
- Integration traffic passes through the DMZ; there is no direct IT–OT session.
For the “has been tested” item on the list, the ERP connection is cut in a test environment or a planned window; it is verified from the records that the queue fills and empties and that no duplicate stock postings are created. For implementing this design and connecting existing systems, see our SCADA, MES and ERP connections service, and for the overall architecture between the corporate network and the production network, our IT/OT integration consulting page.
Frequently asked questions
Is using B2MML mandatory?
It is not mandatory. B2MML is the XML representation of ISA-95 objects and, if both sides support it, reduces arguments about field definitions. Many projects use a REST API or a staging table; even then, defining field names and object boundaries in ISA-95 terms makes the work easier later when a system changes.
Should the bill of materials and routing also be editable in the MES?
Not as master data. The owner of the bill of materials and routing is usually the ERP; making permanent changes in the MES disconnects the two systems. Deviations during production, such as using an alternative material, are recorded in the MES as transaction data and passed to the ERP with the consumption confirmation.
How often should production confirmations be sent to the ERP?
It depends on what the ERP does with this data. For stock and costing, a confirmation at the end of the shift or work order may be enough; if material replenishment and shipping planning look at real-time stock, more frequent confirmations are needed, for example per pallet or lot. Very frequent confirmations create document and locking load on the ERP side.
Should production stop when there is an integration error?
No. The MES should be able to continue production when it cannot reach the ERP and keep confirmations in a queue. For this, enough work orders and master data to cover the outage must have been loaded into the MES in advance. The only situation in which production should stop is when work order or recipe data is missing altogether or inconsistent.