ERP-MES integration is the process of connecting an Enterprise Resource Planning (ERP) system (which handles planning, procurement, scheduling, etc.) with a Manufacturing Execution System (MES) that manages the execution, monitoring, and control of manufacturing processes. The goal is to streamline production processes, ensure real-time data exchange, and improve decision-making by aligning enterprise-level planning with shop-floor execution.
Here is a step-by-step tutorial that incorporates key expert considerations and practical refinements for an ERP-MES integration project using B2MML/XML schemas, aligned with ISA-95 (IEC/ISO 62264). This guide presumes familiarity with ERP/MES systems, XML, and standard web services.

Step 1: Understand ISA-95 and B2MML Basics
Objective
Align with the ISA-95 framework, clarify scope, and familiarize the team with the B2MML schema structure.
ISA-95 Hierarchy
- Define the Integration Scope
- Identify which key data objects will be exchanged (e.g., Production Orders, Material Consumption, Equipment Status).
- Consider whether the integration needs to support real-time updates or batch updates (e.g., daily synchronization).
- Map ERP and MES Data to ISA-95
- ISA-95 defines hierarchical models for Product Definition, Production Scheduling, Performance Analysis, and more.
- Check for site-specific requirements (e.g., if your MES tracks real-time sub-operations, factor that in).
How B2MML Works
B2MML (Business To Manufacturing Markup Language) is an XML implementation of the ISA-95 standard. It defines standardized XML schemas for exchanging data between business systems (ERP) and manufacturing systems (MES, equipment). The format ensures that all systems use the same terminology and structure for commands, responses, and data.
- Data Flow:
- ERP → MES: Sends production orders (e.g., “Produce 100 units of Part X”) as B2MML XML.
- MES → ERP: Returns execution data (e.g., “50 units completed, Machine 3 downtime”) in B2MML format.
Example 1: ERP → MES (Production Order)
Scenario: ERP sends a production order to MES: “Produce 100 units of Part X.”
B2MML XML Structure:
<?xml version="1.0" encoding="UTF-8"?>
<ProductionSchedule xmlns="http://www.b2mml.org" releaseID="ISA-95">
<ProductionRequest>
<ID>PR-2023-001</ID>
<ProductID>Part_X</ProductID>
<Quantity>100</Quantity>
<Priority>High</Priority>
<StartTime>2023-10-01T08:00:00</StartTime>
<EndTime>2023-10-05T17:00:00</EndTime>
</ProductionRequest>
</ProductionSchedule>
Key Elements:
ProductionSchedule
: Root element for scheduling production.ProductionRequest
: Defines the production order details.ID
: Unique identifier for the request.ProductID
: The part or product to be manufactured (e.g., “Part_X”).Quantity
: Number of units to produce.StartTime/EndTime
: Scheduled production window.
Purpose:
- The MES system parses this XML to initiate production, allocate resources, and schedule machine time.
- Aligns with ISA-95’s “Production Schedule” model (Part 3 of the standard).
Example 2: MES → ERP (Execution Data)
Scenario: MES reports back to ERP: “50 units completed, Machine 3 downtime.”
B2MML XML Structure:
<?xml version="1.0" encoding="UTF-8"?>
<ProductionPerformance xmlns="http://www.b2mml.org" releaseID="ISA-95">
<ProductionResponse>
<RequestID>PR-2023-001</RequestID>
<ProductID>Part_X</ProductID>
<CompletedQuantity>50</CompletedQuantity>
<Status>In Progress</Status>
<Equipment>
<EquipmentID>Machine_3</EquipmentID>
<Downtime>
<StartTime>2023-10-02T14:30:00</StartTime>
<EndTime>2023-10-02T15:15:00</EndTime>
<Reason>Maintenance</Reason>
</Downtime>
</Equipment>
</ProductionResponse>
</ProductionPerformance>
Key Elements:
ProductionPerformance
: Root element for reporting production status.ProductionResponse
: Contains execution data.RequestID
: Links to the original ERP order (e.g., “PR-2023-001”).CompletedQuantity
: Units produced so far.Status
: Current state of the order (e.g., “In Progress”).Equipment/Downtime
: Captures machine downtime details.
Purpose:
- ERP uses this XML to update inventory, adjust schedules, and trigger maintenance workflows.
- Aligns with ISA-95’s “Production Performance” model (Part 4 of the standard).
How B2MML Ensures Standardization
- Consistent Terminology:
- All systems use the same definitions (e.g., “Downtime” means the same thing in ERP and MES).
- Hierarchical Structure:
- Mirrors ISA-95’s object models (e.g., Equipment, Materials, Personnel).
- Unique IDs:
- Objects like
ProductID
andEquipmentID
are globally unique across systems, preventing data duplication.
- Objects like
B2MML Schemas
- Download official B2MML schemas from MESA International.
- Review Key Schemas:
ProductionSchedule.xsd
(often used for exchanging Production Orders)MaterialLot.xsd
(for Material/Inventory tracking)Equipment.xsd
(for Equipment definitions and status)
- Versioning: Ensure you have the correct version of B2MML that aligns with your project’s ISA-95 version. Be aware of potential licensing considerations.
Step 2: Define Use Cases and Data Mapping
Objective
Identify specific integration requirements, clarify data flows, and map ERP/MES fields to B2MML.
Example Use Case
- Production Orders: ERP sends a Production Order to MES.
Data Mapping
- ERP Data: Order ID, Product Code, Quantity, Due Date, Routing Steps (if needed), etc.
- MES Data: Work Order ID, Equipment IDs, Detailed Material Requirements, Quality/Test data.
- B2MML Field Mapping
- ERP
OrderID
→ProductionSchedule/ID
in B2MML - ERP
ProductCode
→ProductionRequest/ProductID
- Use XPath or a similar tool for pinpointing B2MML elements (e.g.,
/ProductionSchedule/ProductionRequest/StartTime
).
- ERP
Key Considerations
- Start small with critical fields, but plan for extensions if your organization needs additional attributes (e.g., batch traceability, quality constraints).
- Document each mapped field in a Data Mapping Sheet for maintainability and future reference.
Step 3: Plan the Integration Layer
Objective
Establish a robust middleware or integration API to handle data transformation, routing, and security.
Tools
- Enterprise Middleware: Apache Camel, MuleSoft Anypoint, or IBM Integration Bus.
- Custom Services: Build a lightweight REST/SOAP service using frameworks like Spring Boot (Java) or Flask (Python).
Workflow
ERP System
→ (B2MML XML Generator)
→ Middleware
→ (B2MML XML Parser)
→ MES System
Considerations
- Real-Time vs. Batch: Evaluate how frequently messages must be exchanged. For real-time, consider an asynchronous messaging framework (e.g., JMS, Kafka) with guaranteed delivery.
- Performance: If handling large volumes of production orders, ensure the middleware can scale horizontally or handle concurrency.
Step 4: Develop or Extend B2MML Schemas
Objective
Customize the base B2MML schemas to reflect any unique fields or data models in your ERP/MES environment.
- Start with the Base Schemas
- Use the standard B2MML XSDs (ProductionSchedule, MaterialLot, Equipment, etc.).
- Add Custom Extensions
- Where needed, introduce custom fields (e.g.,
<CustomField>
within a<ProductionRequest>
element). - Version Control: Always track schema changes in a central repository (e.g., Git) and communicate version updates to all stakeholders.
- Where needed, introduce custom fields (e.g.,
Example XML Snippet (Production Order)
<ProductionSchedule xmlns="http://www.mesa.org/xml/B2MML-V0600">
<ID>ORDER_12345</ID>
<ProductionRequest>
<ProductID>PROD_XYZ</ProductID>
<Quantity>1000</Quantity>
<StartTime>2025-05-10T08:00:00Z</StartTime>
<EndTime>2025-05-10T16:00:00Z</EndTime>
<!-- Example extension -->
<CustomField>Batch123</CustomField>
</ProductionRequest>
<EquipmentID>EQP_001</EquipmentID>
</ProductionSchedule>
Tip: Make sure the namespace and schema location match your extended XSD files.
Step 5: Build the ERP Interface
Objective
Extract relevant ERP data and transform it into valid B2MML XML for downstream systems.
- ERP Data Extraction
- Use official ERP APIs (e.g., SAP IDoc, Oracle REST services) or connectors.
- Avoid direct database calls unless necessary; official APIs typically handle transactions and maintain data integrity.
- XML Generation
- Use libraries like Java JAXB, Python lxml, or .NET XmlSerializer.
- Validate the generated XML against B2MML XSDs using tools like XMLSpy, Oxygen XML, or command-line validators.
- Transaction Management
- Ensure your ERP interface respects locking and transaction states (e.g., if an order is partially confirmed, handle accordingly).
- Include fallback strategies or manual overrides in case the ERP is down.
Step 6: Build the MES Interface
Objective
Parse incoming B2MML XML in the MES, then create or update corresponding work orders, material lots, or equipment status.
- XML Parsing
- Parse B2MML using DOM or streaming APIs (SAX/StAX).
- Extract fields like
/ProductionSchedule/ID
and/ProductionSchedule/ProductionRequest/ProductID
.
- MES Integration
- Use MES APIs (e.g., Siemens Opcenter, Rockwell FactoryTalk, Wonderware) to create or update orders.
- Map B2MML
EquipmentID
to the MES’s equipment registry or tag IDs. - If MES is heavily customized, confirm how it handles partial orders or parallel operations.
- Performance & Complexity
- For large or multi-level BOM data, ensure the MES system can handle complex XML structures efficiently.
Step 7: Test with Realistic Sample Data
Objective
Validate the end-to-end data flow, ensuring accuracy and performance under typical and edge-case scenarios.
- Test Scenarios
- Normal case: Send a valid Production Order from ERP to MES, check that the MES work order is created properly.
- Edge cases: Missing fields, invalid XML, large orders, or repeated orders.
- Integration volume: Test high volumes or concurrency if your plant processes hundreds/thousands of orders daily.
- Tools
- Postman or SoapUI to send/receive XML messages.
- Load Testing: Apache JMeter for performance stress tests.
- Validation
- Monitor logs to confirm each message transforms and loads correctly.
- If regulated (e.g., pharma), ensure thorough audit logging and electronic record management is in place.
Step 8: Implement Error Handling and Logging
Objective
Ensure robust handling of integration exceptions and maintain traceability for all transactions.
- Error Handling
- Capture XML parsing/validation errors (e.g., SAXParseException) and categorize them (e.g., “Schema Error,” “Missing Field,” “Data Type Mismatch”).
- Retry strategy: Implement exponential backoff or a queue-based approach for reprocessing failed messages.
- Logging
- Log all incoming and outgoing B2MML messages with timestamps, IDs, and status codes.
- Use centralized log management (e.g., ELK Stack, Splunk, Grafana) for monitoring.
- Define clear error messages to expedite troubleshooting (e.g., “Order ID Missing” vs. “XML Invalid”).
- Governance
- Establish an incident resolution process: Who gets notified? How quickly must issues be resolved?
- Keep an audit trail of any manual overrides or corrections.
Step 9: Secure the Integration (ISA/IEC 62443)
Objective
Protect confidential data and comply with industrial cybersecurity standards.
- Encryption & Authentication
- Use HTTPS/TLS for data in transit.
- Encrypt sensitive fields (e.g., <MaterialLot> with expiration details) if required by company policy or regulations.
- Implement OAuth 2.0 or API keys to authenticate ERP and MES endpoints.
- Network Segmentation
- If integrating across IT/OT boundaries, use DMZs, firewalls, and VLAN segmentation as recommended by ISA/IEC 62443.
- Regularly patch and secure the middleware platform to minimize vulnerabilities.
- Access Control
- Enforce role-based access and strict permission sets.
- Audit user actions that alter B2MML schemas or data mappings.
Step 10: Deploy and Monitor
Objective
Roll out the solution in a controlled manner and ensure ongoing reliability.
- Phased Rollout
- Begin with a pilot line or small product family to limit risk.
- Expand to additional lines/plants once you’re confident in stability and performance.
- Monitoring & KPIs
- Track latency for each transaction (ERP → MES and MES → ERP).
- Set alerts for Schema Validation Failures, High Error Rates, or Excessive Processing Time.
- Business Continuity
- Define fallback processes if ERP or MES systems go offline.
- Have manual data entry procedures in place if integration flows fail, so production is not halted.
Additional Tools & Libraries
- B2MML Schema Validator: W3C XML Validation Tools or commercial products (XMLSpy, Oxygen).
- Middleware: Apache Camel, MuleSoft Anypoint Platform.
- ERP/MES Connectors: SAP PI/PO, Wonderware connectors, Oracle SOA Suite.
- Testing: Postman, SoapUI, JMeter.
- Logging/Monitoring: ELK Stack (Elastic), Splunk, Grafana.
Compliance and Documentation
- Documentation
- Maintain data mapping sheets, integration flow diagrams, and error code references.
- Keep a version history of XSD extensions and transformation logic.
- Compliance
- Align with ISA-95 Part 2 (object models) and Part 4 (operations management).
- Adhere to ISA/IEC 62443 for ICS/OT security and any applicable industry regulations (e.g., FDA 21 CFR Part 11 in pharma).
How to Extend ERP-MES Integration Using B2MML/XML to Control Systems
B2MML (Business To Manufacturing Markup Language) is designed for high-level system integration (e.g., ERP ↔ MES) and operates at Level 3-4 of the ISA-95 automation hierarchy. SCADA systems (Level 2) and PLCs (Level 1) work at lower, real-time control layers. While B2MML is not natively used to communicate directly with SCADA/PLC systems, integration is possible through protocol translation and middleware. Extending the integration involves bridging MES with control systems using ISA-95 Level 3 (MES) and Level 2 (Control Systems). Here’s how it can be done:

1. Use B2MML to Define Data Exchange
- B2MML (Business-to-Manufacturing Markup Language) is already based on ISA-95.
- It provides structured XML schemas that can be extended to define:
- Production Schedules → Sent from ERP to MES to Control Systems.
- Production Performance Data → Collected from Control Systems via MES and sent to ERP.
- Quality & Process Data → Fetched from control systems to MES for analytics and reporting.
2. Implement a Middleware/Message Broker for Communication
- Control systems (PLC, SCADA, DCS) often communicate using OPC UA, MQTT, or Modbus.
- Middleware (e.g., MQTT Broker, OPC UA Server, or IoT Gateway) can act as a bridge between MES and control systems.
- The middleware converts real-time shop-floor data into structured B2MML/XML messages for MES/ERP.
B2MML ↔ SCADA/PLC Communication Flow
The connection requires intermediary systems to translate B2MML’s XML-based data into protocols that SCADA/PLC understand (and vice versa).
Example Workflow:
- MES to SCADA/PLC:
- Step 1: MES sends a B2MML production order (e.g., “Produce 100 units of Part X”).
- Step 2: A gateway/middleware (e.g., an industrial IoT platform or edge device) parses the B2MML XML.
- Step 3: The middleware translates relevant data (e.g., quantity, product ID) into a SCADA/PLC-friendly protocol like OPC UA, MQTT, or Modbus.
- Step 4: SCADA forwards commands to PLCs (e.g., start Machine 3, set parameters).
- SCADA/PLC to MES:
- Step 1: PLCs send real-time data (e.g., “Machine 3 temperature = 75°C”) to SCADA via protocols like Modbus TCP or Ethernet/IP.
- Step 2: SCADA aggregates data and forwards it to middleware.
- Step 3: Middleware packages the data into B2MML XML (e.g.,
<ProductionPerformance>
with equipment status). - Step 4: MES receives B2MML data for analysis and reporting.
Key Challenges
- Protocol Mismatch:
- B2MML uses XML, while SCADA/PLC rely on lightweight, real-time protocols (e.g., OPC UA, Modbus).
- Example: A PLC cannot parse XML natively—it requires middleware to extract values like
Setpoint=100
from B2MML and send them as Modbus registers.
- Data Granularity:
- B2MML describes high-level orders (e.g., “Produce 100 units”), while PLCs need low-level instructions (e.g., “Activate Motor A at 500 RPM”).
- Latency:
- Real-time control (PLCs) requires millisecond responses, whereas B2MML exchanges are slower and batch-oriented.
How Translation Works
Example: B2MML → PLC Commands
A B2MML production order:
<ProductionRequest>
<ID>PR-2023-001</ID>
<ProductID>Part_X</ProductID>
<Quantity>100</Quantity>
</ProductionRequest>
Middleware Action:
- Extracts
ProductID=Part_X
andQuantity=100
. - Maps these to PLC-specific commands:
Part_X
→ Load CNC program “G-Code_X” on Machine 3.Quantity=100
→ Set Counter Register 40001 to 100.
- Sends commands via OPC UA or Modbus TCP.
Example: PLC → B2MML Feedback
Machine3.Status = Running Machine3.UnitsProduced = 50
Middleware Action:
- Converts to B2MML:
<ProductionPerformance> <ProductionResponse> <RequestID>PR-2023-001</RequestID> <CompletedQuantity>50</CompletedQuantity> <Status>In Progress</Status> </ProductionResponse> </ProductionPerformance>
3. Automate Production Execution & Feedback Loop
- ERP sends orders → MES translates them into detailed work instructions.
- MES then dispatches tasks to Control Systems using B2MML Process Segment and Production Schedule schemas.
- Control Systems execute the tasks and send real-time production updates (machine status, material consumption, quality results) back to MES.
- MES consolidates this data and forwards it to ERP for analysis and decision-making.
4. Implement Edge Computing & IoT for Data Acquisition
- Edge devices (IoT-enabled sensors, smart controllers) can collect real-time data from control systems.
- This data can be structured in B2MML-compliant XML messages and sent directly to MES.
- Example: An IoT-enabled smart meter measuring energy consumption can feed live data to MES, which optimizes resource usage.
5. Use Standard APIs/Web Services for Interoperability
- Many modern MES platforms support RESTful APIs or SOAP web services that can encapsulate B2MML XML messages.
- Control systems with OPC UA Servers can expose real-time data to MES in a structured format.
- Using API gateways, MES can retrieve this real-time shop-floor data and pass it to ERP.
Example Workflow: ERP → MES → Control Systems
- ERP sends a production order to MES in B2MML Production Schedule format.
- MES translates the order into machine-level instructions (e.g., start/stop commands, process parameters).
- MES sends control commands to PLCs/DCS via OPC UA or MQTT in B2MML XML format.
- Control Systems execute the task (start machine, mix ingredients, monitor quality).
- Control Systems send real-time status updates to MES.
- MES aggregates data and forwards KPIs, performance reports, and alerts to ERP.
- ERP uses this data for decision-making (e.g., adjusting future schedules, procurement, or maintenance planning).
Our ERP-MES-Control Systems Integration Expertise Available
We specializes in ERP-MES integration using industry standards such as ISA-95 and B2MML/XML, ensuring seamless data exchange, secure real-time synchronization, and scalable system growth. Whether you need customized ERP interfaces, advanced MES solutions, or comprehensive IT consulting, our proven methodologies and step-by-step guidance empower your digital transformation.