Skip to Content
Technical Articles
Author's profile photo Roman Gorbenko

Integrate it! – SAP and MES integration. Step-by-step guide


“The increased scale and complexity of SAP and non-SAP systems challenges require that we look for
ways to simplify the system-integration requirements”
This quote about a series of blog-posts (“Integrate it…”) about integration between different SAP and non-SAP systems
Another posts from this series (The list is being updated.)


Manufacturing execution systems (MES) are computerized systems used in manufacturing, to track and document the transformation of raw materials to finished goods. MES provides information that helps manufacturing decision-makers understand how current conditions on the plant floor can be optimized to improve production output. MES works in real-time to enable the control of multiple elements of the production process (e.g. inputs, personnel, machines, and support services).
MES may operate across multiple function areas, for example, management of product definitions across the product life-cycle, resource scheduling, order execution, and dispatch, production analysis and downtime management for overall equipment effectiveness (OEE), product quality, or materials track and trace. MES creates the “as-built” record, capturing the data, processes, and outcomes of the manufacturing process. This can be especially important in regulated industries, such as food and beverage or pharmaceutical, where documentation and proof of processes, events, and actions may be required.

Benefits of MES:

  1. Reduced waste, re-work, and scrap, including quicker setup times
  2. More accurate capture of cost-information (e.g. labor, scrap, downtime, and tooling)
  3. Increased uptime
  4. Incorporate paperless workflow activities
  5. Manufacturing operations traceability
  6. Decreases downtime and easy fault finding
  7. Reduced inventory, through the eradication of just-in-case inventory
Common use cases where MES system integrated with SAP EWM and/or SAP ERP systems
MES-system consume a master-data (Materials, Batches, Containers and so on) from ERP-system


You want to know more about SAP-MES Integration with SAP PI/PO in the outline.



Step 0. Intro

In this integration scenario:
Message bus (integration broker) – SAP PO
Let’s first take a quick look at the integration scenario blueprint:

Step 1. Examples of message flow

  1. Materials from ERP to MES
  2. Batches from ERP to MES
  3. Deliveries from ERP to MES
  4. Handle Units from ERP to MES
  5. Process Orders from ERP to MES
  6. Materials from MES to ERP

Step 2. Integration from SAP PO Standpoint

Step 2.1.From the Enteprise Service Repository (ESR) perspective:

Describe message flow from Step 1
1.Software Component Version Name
3.DataTypes (DT) objects
Example of Material flow
Elements: MaterialType, MaterialNumber, Brand and so on
4. MessageTypes (MT) objects will be generated automatically from DT
5. In/Out Service Interface (SI) objects
Assign Request Role to created MT and Fault Role to Fault Message Type
6.Receive / Send Actions
Assign Receive Action with In Service Interface
Assign Send Action with Out Service Interface

Step 2.2. From the Integration Builder (IB) perspective

For Web-service (SOAP):
  1. the Route to/from MES System
Configuration Component Without Party – Bussines System – (for example BSYSTEM_MES_QAS)
Adapter Type – SOAP
SOAP Sender Communication Channel
SOAP Receiver Communication Channel (Target URL to MES Web Service with Credentials and Port Number)
Configuration Component Without Party – Bussines System – (for example BSYSTEM_S4HANA_CLIENTXXX_QAS)
Adapter Type – SOAP
Adapter – Sender
Transport Protocol – HTTP
Addressing Type – HTTP Destination
HTTP Destination – Name of HTTP Destination
SOAP Sender example:
  1. The route to/from ERP System
Configuration Component Without Party – Bussines System – (for example BSYSTEM_MES_QAS)
Adapter Type – SOAP
Adapter – Receiver
SOAP Sender Communication Channel
SOAP Receiver Communication Channel (Target URL to MES Web Service with Credentials and Port Number))
SOAP Receiver Example:
For IDoc Integration:
Configuration Component Without Party – Bussines System – <SID>CLNT<CLNT> (Name suggestion,for example)
Communication Channel settings:
Bussiness System – <SID>CLNT<CLNT> (Name suggestion,for example)
Adapter Type – IDoc_AAE
Adapter Type –  Receiver
Transport Protocol – tRFC
Messgae Protocol – IDOC XML
Adapter Engine – Central Adapter Engine
IDoc Sender Example:
For Integrated Configuration (ICO) in IB:
For Configuration Scenario in IB:
For example Batch Replication Configuration Scenario.
N.B. More than one system can be as a target system for a Master Data workflow
Model Configuration:
Source system – SAP ERP
Target systems  – MES, 3d party BI software and so on

Step 3. Integration from ERP standpoint

Step 3.1. IDOC Integration


IDoc, short for Intermediate Document, is a SAP document format for business transaction data transfers. The IDoc itself is a structured Text-File, that means IDocs can be used on all platforms, there is no need to translate binary data
SAP transactions:
Step 3.1.1. Settings in SM59
Transaction SM59 –   Configuration of RFC Connections
Connection Type – T (TCP/IP Connections)
Gateway Host  –   Path to SAP PI/PO
Program ID –
1)A RfcAdapter sender channel registers itself with this Program ID as a RFC-Server at the SAP Gateway. The sending system uses the same Program ID to identify the RFC-Server at the SAP Gateway.
During the sending system sends some RFC calls, the SAP Gateway will search its registration list for the Program ID supplied by the sending system
2)The Program ID is case sensitive.
3)The same Program ID should be given in RFC Sender Channel.
Gateway service – sapgw<SID>

Step 3.1.2. Settings in WE31

Transaction – WE31 – Development IDoc Segment
Bindings between IDoc Segment and Data Elements
For example Segment type E1BATMAS and Fields in Segment like as MATERIAL

Step 3.1.3. Settings in WE81

Transaction – WE81 – Logical Message Types
For example:
SAP Object – MATERIAL has a standard IDoc Message Type MATMAS. In transaction WE81 we can create custom message type, for example, ZMATMAS.

Step 3.1.4. Settings in SM30

Transaction – SM30 – Maintain Table View – V_TBDA2
Activate change pointer for custom Message Type

Step 3.1.5. Settings in WE82

Transaction – WE82 – Assign Messages for IDoc Type
Binding between custom message type and basic message type.

Step 3.1.6. Settings in BD61

Transaction – BD61 – Activate Change Pointers Generally
Set Change pointers activated – generally.

Step 3.1.7. Settings in BD50

Transaction – BD50 – Activate Change Pointers for Message Type
Activate Change Pointer for our Custom message type

Step 3.1.8. Settings in BD52

Transaction – BD52 – Activ. Change Pointer per chng doc it
Bindings between change document items and custom message type
For example bindings between Message type ZXXX and
CHARGE_LM – Batch master (with a long material number)
MCHA – Batches (table)
LICHA – LICHA    Supplier Batch Number (field)

Step 3.1.9. Settings in BD64


Transaction – BD64 – Display Distribution Model
We can add a message to the Distributon model.
1.Create Distribution model
2.Add to Distribution model ERP and PI systems
3. Add to Distribution Model Message Type. For example LOIPRO (Production Order)

Step 3.1.10. Settings in WE21

Transaction – WE21 – Ports in IDoc processing
Binding IDoc port with RFC port defined in step 3.1.1

Step 3.1.11. Settings in WE20


Transaction – WE20 – Partner profiles
Bindings between Message Type and Receiver Port
Partner type/role is used to identify partners within the sap systems. Partner type is KU for a customer, LI for vendor and LS for Logical System.

Step 3.2. RFC Integration


Step 3.2.1. SPROXY


Transaction – SPROXY – Enterprise Repository Browser
Consume SAP PO ESR objects here.
Bindings between generated z-structure from  SAP PO Data Type and you custom code which populated data to this z-structure

Step 3.2.2. ABAP Development


Transaction – SE80 – Object Navigator and other development tools like an SM30 and SE38
(creation of package / subpackages, structures, function modules, programs and so on)
For example Generated Proxy Z-Structure for Material

Step 3.2.3. Scheduling


Transaction – SM36  – Schedule Background Job


SE38 -> Create variant for each message type used in SAP-MES integration. RBDMIDOC Report -> Create Variant
SM36 -> Create Background job for each variant of  RBDMIDOC Report
Periodic time, for example, each 5 minutes

For RFC:


SM36 -> Create Background job for each custom ABAP program which sends data to integration

Step 4. Integration from MES standpoint

A quick look at the integration scenario from the MES standpoint.
For example MES system with integration part based on Apache Camel.
Small quote about architecture:
“ERP data is exchanged as XML text files that comply with a selected set of SAPIDOCs. The IDOCs from a file system is transformed from XML to common business objects and delivered to FTPC through JMS message queues. Using an event sheet, Shop Operations Server reads the messages from this queue and launches a specific activity set to process each message.”
Architecture and configuration:
Integration Configuration:
Java Message Service Providers:
  • Inbound Configuration
  • Outbound Configuration

Step 5. Monitoring

Monitoring from the ERP side:
Transaction – WE02 (Display IDoc)
Transaction –  WE05 (IDoc List)
Message 29 – Error in ALE service
Transaction – BD87 – Status Monitor for ALE Messages
Status Monitor for ALE Messages for example status for LOIPRO (Production Order)
Transaction – SXMB_MONI (Integration Engine Monitoring)
Monitor for Processed XML Messages
Transaction SMQS – TRFC Monitor
Monitoring from the SAP PO side:
SAP Netweaver -> Configuration and Monitoring Home
Adapter Engine ->Message Monitor
Monitoring from the MES side:
This step depends on the type of MES system. For Rockwell Factory Talk  this is Inbound Events Monitor


Transaction SMQS – TRFC Monitor
Queue in error ” Failed to resolve repository reference @XI_IDOC_DE FAULT_DESTINATION
SAP PI – SAP Netweaver Administrator – Configuration – Destinations
Check credentials, ping, etc for destination XI_IDOC_DE FAULT_DESTINATION



Idoc Error Status “Entry in outbound table not found”
IDoc Basics For Functional Consultants
137412 – Creation of the batch – no change pointer for ALE


SAP-MES Integration with SAP PI/PO in outline provided

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Roman Gorbenko
      Roman Gorbenko
      Blog Post Author

      Update 07/10/2020. Section Troubleshooting was added

      Author's profile photo sreenivasa veldanda
      sreenivasa veldanda

      Can you share same process with CPI.

      Author's profile photo Mohammed Ilyas Guttal
      Mohammed Ilyas Guttal

      Can you please share the same process with CPI/CI