Skip to Content
Technical Articles
Author's profile photo Dominik Tylczynski

How to setup and run PLC emulator for SAP EWM MFS

Introduction

The open source PLC emulator is available as the copyleft GitHub repository mfs-plc-sim for everyone to clone, build and run. Still building the emulator might get challenging. The intention of this article is to help with the process. Unfortunately due to redistribution restrictions of SAP Java Connector license terms, I must not provide self contained, ready to run, single jar file.

Prerequisites

The emulator relies on SAP Java Connector and Apache log4j2 libraries. They need to be installed before running the PLC emulator:

Downloading the PLC emulator

Download the following files from the the GitHub repository mfs-plc-sim:

For convenience put all the files in a single directory.

Setting it all up

Logging configuration

Refer to Log4j Configuration for the detailed documentation on how to setup the logging options. Provided log4j2.xml sets debug level logging with a rich patter and directs the messages to the console. It can be left as it is.

JCo configuration

Java Connector configuration is composed of two files:

  • SID.jcoDestination – the file defines your SAP system destination and how to log to it
  • PROGID.jcoServer – the file defines the RFC destination to be used with EMW-MFS

Rename and modify the content of the files. For instance, let’s say we are connecting to a single SAP sandbox installation running on 192.168.1.1 address, system number 01, client 100, system id DEV – so we need DEV.jcoDestination file:

jco.client.user=JDOE
jco.client.passwd=password
jco.client.lang=EN
jco.client.client=100
jco.client.ashost=192.168.1.1
jco.client.sysnr=01
jco.client.r3name=DEV
jco.destination.pool_capacity=3

Next, let’s say that our RFC destination is defined with MFSPLC program id. So we need MFSPLC.jcoServer file:

jco.server.gwhost=192.168.1.1
jco.server.gwserv=3301
jco.server.progid=MFSPLC
jco.server.connection_count=1
jco.server.repository_destination=DEV

Refer to JCo documentation on the details of the configuration.

The PLC emulator configuration

The emulator is customized with Java properties file. A sample MFS.properties file is provided. The most important entries are:

telegramStructure=ZMFS_TELESHORT
handshakeRequest=R.
handshakeConfirmation=A.
switchSenderReceiver=false

Additionally telegram styling can be customized:

Style.LIFE-R.=255,0,0,B
Style.LIFE-A.=255,0,0,I

The value of each key is interpreted as:

  • R,G,B font color specification
  • BIUS – characters specifying font options:
    • B – bold
    • I – italic
    • U – underlined
    • S – strikethrough

For instance 255,255,0,BI yields yellow, bold, italic styling.

Running the emulator

Run the RFC-TCP/IP bridge with the command:

java -Dlog4j.configurationFile=log4j2.xml -cp sapjco3.jar:log4j-api-2.19.0.jar:log4j-core-2.19.0.jar:mfsplc.jar pl.sapusers.mfsplc.bridge.Bridge MFSPLC MFS.properties

Run the emulator application with the command:

java -Dlog4j.configurationFile=log4j2.xml -cp sapjco3.jar:log4j-api-2.19.0.jar:log4j-core-2.19.0.jar:mfsplc.jar pl.sapusers.mfsplc.sim.Sim DEV MFS.properties

The commands may need to be modified if your jar files do not reside in the working directory.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Malick Thienpont
      Malick Thienpont

      Hi Dominik, great blog and currently really relevant for our project!

      I have some additional questions though:

      - How easily can we switch between different telegram types?

      - Do we need a seperate PLC in SAP EWM dedicated to the PLC sim? Or can we link all of our/multiple PLC's in SAP EWM with it?

      Thank you in advance for your feedback.

      Keep up the good work! 🙂

      Kr,
      Malick

      Author's profile photo Dominik Tylczynski
      Dominik Tylczynski
      Blog Post Author

      Hello Malick Thienpont

      As indicated in the Open source PLC emulator for SAP EWM MFS in action blog, I have used /SCWM/MFS_* BC sets to setup demo processes during the emulator development. Therefore I have used the telegram types as defined in the /SCWM/MFS_TELEGRAM_TYPES BC set:

      Actually the only hardcoded telegram type is LIFE that I use to filter out life telegrams from the communication log.

      In terms of telegram structures each instance of the Sim class is using a single telegram structure, that is defined in the properties file with the property telegramStructure.

      It is on my to-do list to implement configurable telegram types and allow various telegram structures. See the issues list of the PLC sim project. Feel free to add your own feature requests.

      You don't really need to customize a dedicated PLC for PLC sim, you can use the existing ones provided the fit the current limitations. The goal of the emulator is to connect with the existing PLC setups. Let me know please how the emulator fits your project.

      Author's profile photo Patrick Rogge
      Patrick Rogge

      Hello Dominik,

      sorry for bothering you,but when I try to start bridge or sim I always get the error:

      Error: Main class pl.sapusers.mfsplc.sim.sim  or pl.sapusers.mfsplc.bridge.bridge couldn't be found or loaded.

      Any hints for me to get rid of that issue?

      Thanks in advance

      Patrick