Simulation / Emulation

This blog is part of the series ‘SAP EWM meets Automation – Discover EWM MFS’. As with all posts of this series, the content provided here has been created in cooperation with the SAP EWM team at Swisslog. Feel free to visit their website in case you want to learn more about the services offered by Swisslog or to browse open positions within their EWM team!

With this blog post I look into the EWM standard simulation/emulation which you can use within your MFS projects in case you do not have the possibility to test/work with the real hardware/subsystems (yet).

Before we look into the agenda, let us tackle the question “What is the difference between a simulation and an emulation and what do we have in standard EWM MFS?”.

Simulation vs. Emulation

I give you my interpretation right at the beginning –

I do think what we have in EWM standard can be described with the term ‘Emulation’. This is at least my understanding based on the definitions that I found while researching this topic/question. Here is a collection of descriptions & definitions that helped me coming to my conclusion.

It's a difference in focus. Emulators focus on recreating the behavior of a system, with no regard for how the system functions internally. Simulators focus on modeling the components of a system. You use an emulator when you care mostly about what a system does, and a simulator when you care about how it does it.

Emulation comes from æmulus, "striving, rivaling," and is related to "imitate" and "image," which suggests a surface-lever resemblance. "Simulation" comes from similis "like", as does the word "similar," which perhaps suggests a deeper congruence.

By that I mean that you use an emulator when you can't use the real thing, and you use a simulator when you can't use the real thing and you want to find something out about it.

An emulator is an alternative to the real system but a simulator is used to optimize, understand and estimate the real system.

Source: https://stackoverflow.com/questions/1584617/simulator-or-emulator-what-is-the-difference

The flow of loads within the simulation are controlled by algorithms developed to closely mirror how the system would be controlled by a real WCS or WMS.

An emulation model is generated and is used to test and commission the WCS controls software. Interfaces within the emulation model allow the WCS to connect as it would connect to the real Automated Material Handling System.

Source: https://www.logistex.com/post/why-simulating-emulating-warehouse-automation-makes-sense

Conclusion –

As mentioned above, I do think that we have an emulation in EWM standard although the name & description of the function module that EWM offers (details later) indicates that it provides a simulation. Anyways – for me it is an emulation and hence, for the rest of this article I will stick to this term.

Having answered this initial question, let us look the agenda for the remaining part of the blog-post:

Purpose / Use-cases

The emulation in EWM is needed during the development & testing phase, when

So what are the things that you can test with the standard emulation and what can it not be used for?

I start with a list of things where it can really be useful:

Routing: LOSC / Case Conveyor Routing

Validation of format & content of outgoing telegrams

Processing of incoming telegrams with different content

Having discussed the areas where the emulation is useful, let us now focus on the areas where it is not useful or at least does not really help you to validate your setups.

Communication layer

Processing on subsystem side

Emulation in the context of material flow systems

Let us now become a bit more functional/technical and first analyze the approach of emulating a subsystem in the context of a material flow system (no matter whether it is EWM controlling the MFS or any other WMS or MFC). You already know the graphic below in case you followed my blog so far. This is looking at the real world. The PLC is processing signals and communicates with EWM based on telegrams (green arrows). In the other direction, EWM is sending telegrams towards the PLC in order to make it activate/deactivate signals & sensors (orange arrows):

SAP EWM MFS Simulation Emulation 1

SAP standard now gives us an option that we can use in order to send & receive telegrams without a PLC and even without a non-SAP software to emulate the PLC. We do only need our standard EWM system – nothing else.

Function module /SCWM/MFS_SIM_RECEIVE is used for this purpose. Before we look into the details of this FM, let us do some more preparation work in order to understand the role of this FM.

Steps to communicate with a real subsystem

EWM processes the telegram via FM /SCWM/MFS_RECEIVE2 (e.g. confirms the open EWM task which belongs to the given HU)

SAP EWM MFS Simulation Emulation 2

Steps with the EWM emulation

EWM processes the telegram with FM /SCWM/MFS_RECEIVE2 in the same way as if it would be talking to a real subsystem (e.g. confirm the open EWM task which belongs to the given HU)

SAP EWM MFS Simulation Emulation 3

The concept as such should be clear now. But what needs to be done in order to involve the emulation function module and how does the FM actually knows what it needs to return?

Let us first look at the required configuration as this is rather simple.

Configuration

The only thing you need to do is to maintain the emulation function module as the sending FM in the PLC application data via transaction /SCWM/MFS_PLC:

SAP EWM MFS Simulation Emulation 4
SAP EWM MFS Simulation Emulation 5

That’s it! With this setup EWM will send its telegrams to the emulation FM instead of an external subsystem. So how is this FM now able to send us the response that we need in order to achieve the objectives that we defined at the beginning of this blog post? (test the routing, validate the format/content of outgoing telegrams, validate the telegram processing FMs etc.).

Let us look into detail – time for a code-review!

Code-Review

Function module /SCWM/MFS_SIM_RECEIVE

SAP EWM MFS Simulation Emulation 6

First of all it is important to understand the importing variables of the FM. Remember, the FM is replacing the subsystem as a communication partner. So where MFS usually hands over a telegram to the subsystem (e.g. via calling a middleware/RFC-converter or the PLC directly via ABAP-Push-Channel), we do now handover this telegram to the simulation FM:

SAP EWM MFS Simulation Emulation 7

As a preparation for processing this telegram, the FM reads additional PLC and channel data based on the imported variables and moves the imported telegram data into the generic telegram structure /SCWM/S_MFS_TELETOTAL (this structure has all fields of all telegrams and simplifies processing in EWM MFS from technical perspective):

SAP EWM MFS Simulation Emulation 8
SAP EWM MFS Simulation Emulation 9

As part of the next step, EWM checks whether the telegram requires an acknowledgement to be sent to the sender (which is EWM here). Whether or not this is to be done depends on the protocol/handshake settings of the communication channel:

SAP EWM MFS Simulation Emulation 10
SAP EWM MFS Simulation Emulation 11

If the acknowledgement is created successfully, the emulation FM calls the standard FM to receive telegrams in EWM (/SCWM/MFS_RECEIVE2) in order to process it (so you can see already that you can use the emulation FM also in order to test the handshake settings of your communication channel).

Now the core of this emulation FM begins. Based on the telegram received, it now creates a response telegram and hands it back to the telegram receiving logic of EWM MFS.

When you look at the case-statement here, you will easily understand the whole logic of the standard emulation (which I also tried to explain at the beginning of this section).

The statement just goes through all of the possible outgoing telegram categories and based on the category of the outgoing telegram it determines the category of the one which it now creates as a response:

SAP EWM MFS Simulation Emulation 12
SAP EWM MFS Simulation Emulation 13

Example for the most obvious one:

Incoming telegram to be created should be a warehouse task confirmation

Pretty simple. EWM standard covers

Warehouse task cancellation > Cancellation confirmation

SAP EWM MFS Simulation Emulation 14
SAP EWM MFS Simulation Emulation 15

Having determined the category for the response, the next step is to build the response telegram. This is done by either FM /SCWM/MFS_BUILD_TELEGRAM (for channel synchronization) or FM /SCWM/TMFSTELTO_READ_SINGLE (for all other scenarios mentioned above):

SAP EWM MFS Simulation Emulation 16

If you’ve expected complex logic here I have to disappoint you. Both are mainly used in order to determine the telegram type for the response telegram based on the category determined above. The other content of the telegram structure is not really changed and simply copied from the outgoing telegram.

As we have telegram content and type now, the only steps left are:

…and finally call FM /SCWM/MFS_SIM_SEND which is doing nothing else than starting a new task, wait for 3 seconds and then call FM /SCWM/MFS_RECEIVE2:

SAP EWM MFS Simulation Emulation 17 1

Those of you who are following my blog already know that this FM is the one which is responsible to process all incoming telegrams in EWM MFS (check this blog post in case you want to learn more about how EWM processes incoming telegrams).

So you see that the emulation is calling the exact same coding for incoming telegram processing that would be called in case a real subsystem would have sent this telegram to EWM!

SAP EWM MFS Simulation Emulation 18

…and that’s it from technical perspective in terms of EWM Standard Emulation!

Summary

Final words -

Last but not least I would like to mention that you will most probably not be able to emulate your MFS project entirely with the standard emulation. Projects tend to be more complex and all subsystem vendors have their own telegram types along with specific requirements for an emulation. Having said that, the standard FM provides a good starting point and option to use it as a copy-template for your Z-Emulation!

📧 Newsletter

Get updates about new blog posts directly in your inbox.

▶️ YouTube Channel

Subscribe to my channel for regular tutorials & insights about SAP EWM.

Subscribe on YouTube