Monday 7 May 2018

SAP IoT and SAP NetWeaver AS for ABAP Channels

Buzz about IoT


Technology is evolving everyday. Businesses are throwing challenges on technology and now technology is also challenging businesses in different ways.These days one can hear lots of buzz words like Cloud, Cloud Foundry, Cloud Platform, Industry 4.0, SAP IoT, Machine Learning, Artificial Intelligence, SAP Leonardo, SAP Co-pilot, SAP chatbot etc. All these buzz words are music to some people’s ears but there are still some people who are trying to connect dots and trying to understand how all these fit in context with SAP.

In this blog I would like to pick up one of those words which is SAP IoT and will try to put some context around it. I am sure most of people have heard word IoT in one way or another. If you end up on this blog while your search there is a big chance you were searching for SAP + IoT or something along same lines.

IoT stands for ‘Internet of Things’. To familiarize yourself with general concept you can search internet for this term or for a quick read you can refer to Wikipedia about IoT.

How about SAP IoT without SAP IoT Platform??!!!


Although SAP IoT platform provides comprehensive sets of tools to get you up and running with your business specific scenarios but WHAT IF:

◈ It’s too expensive to use SAP IoT Platform
◈ The business case for SAP IoT is too small
◈ Business needs to evaluate IoT options with existing SAP infrastructure

The answer to WHAT IF in all above cases along with numerous other cases where you would want to take small steps towards the world of IoT lies in your core SAP ECC on-premise system. Yes you can utilize your current SAP ECC system and mimic some of IoT functions.In SAP Application Server ABAP 7.40 Support Package 05 a new concept was introduced via infrastructure for event based communication. The new concept is called ABAP channels created in SAP NetWeaver Application Server ABAP. Now with SAP Netweaver Application Server ABAP 7.51 there is improved support of Industrial IoT scenarios. You can see SAP official roadmap for SAP Netweaver Appliacation Server ABAP which talks about industrial IoT with ABAP channels.

A. Simple Example of Temperature Sensor WITH SAP IoT Platform


There are numerous blogs available on this simple example case for SAP IoT. If you are SAP Developer/Architect/Consultant and would like to try your hands on following are pre-requisties:

◈ SAP Cloud platform Trial Access
◈ Familiarization with SAP Cloud platform

Internet of Things Service in SAP Cloud Platform


Before you can use SAP Cloud Platform Internet of Things you have to enable it in your SAP Cloud Platform Cockpit.

In your SAP Cloud Platform Cockpit navigate to “Services” section and click on “Internet of Things” tile.Please click on ‘Enable’ if it’s not already ‘enabled’.

For next step please click on “Go to Service” .

Internet of Things Cockpit


The following steps in internet of things cockpit will show you how to create a Device Type and Message Types associated with it as well as a Device instance. In below screen-shot you can see I have one message type, one device type and one device registered.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Create Message Type


Click on Message Types tile in your Internet of Things Cockpit.

Click on the + button and this will open screen to create new message type.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

I have created following message type with field name as temperature.

Fields:

◈ temperature : float

Please make note of the Message ID. We will need that later

Create New Device Type


Please click on Device Types tile in your Internet of Things Cockpit.

Please click on + button to add a new device type.

On screen add following data:

◈ Enter the Name “TemperatureSensor”
◈ Choose the message type you just created
◈ Choose the message direction “Bidirectional”

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Create New Device


Click on Devices tile in your Internet of Things Cockpit.

Click on the + button to add a new device.

Please fill in following information on the screen-shown

◈ Enter a Name
◈ Choose the device type you just created

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Please make a note of the Device ID. We will need that later.

Deploy the Message Management Service (MMS)


The deployment of the Message Management Service (MMS) is done from the “Deploy Message Management Service” tile in the Internet of Things Cockpit.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

You need to assign Role IoT-MMS-User for the newly deployed iotmms Application (otherwise you will be denied access to the iotmms Application URL with an HTTP Status 403 Error). To do so:

◈ In your SAP Cloud Platform Cockpit go to JAVA applications
◈ Choose the iotmms application
◈ Choose the Security tab of the Application details and then select Roles

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Do the assignment of the role to your user.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Once MMS is deployed and you have correctly done role assignment you can click on the iotmms Java application URL in your SAP Cloud Platform Cockpit and get to the MMS Cockpit as shown below. It provides access to the MMS API as well as a “Display stored messages” tile for the access to data received from IoT Devices.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Configure the Message Management Service


I will be publishing data via MQTT over TCP. I am using public and free MQTT provider  iot.eclipse.org, you can use any other MQTT provider if you like.

To store data being provided by MQTT provider, we must also connect the MMS service to the MQTT broker.

Click on “Configuration the Message Management Service” tile:

◈ Enter the MQTT Broker Endpoint, for my application I have entered tcp://iot.eclipse.org:1883
◈ Enable the MQTT Connection
◈ Enter the Password: sapcloud
◈ Enter the User Name: sapcloud

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Test Connection


Click on “Messaging through MQTT over TCP” tile.

Enter the Device ID and click Connect. To publish the message please use the message type id which in my case was id associated with mqtt and compose message as following:

{“mode”:”async”,”messageType”:”17170e9e0a99a73e32b8″,”messages”:[{“temperature”:”59″}]}

I have send 10 different temperature readings one by one by changing temperature value. These temperature values are same which I used in my SAP ABAP channels application.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Output of Application


You can see output of this application by going to tile ‘All Registered Device’ from your Internet of Things Service Cockpit:

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Result A:

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

B. Simple Example of Temperature Sensor WITHOUT SAP IoT Platform


There are lots of really informative blogs available from Olga Dolinskaja for SAP Netweaver. I have followed following blog step by step which shows how to achieve same result as in above SAP IoT example WITHOUT SAP Cloud platform and using SAP ABAP channels.

How ABAP supprots industrial IoT scenarios with Real-time UIs

Once you have followed all steps mentioned in Olga’s post you will end up with an SAPUI5 application which is also showing temperature sensor data on a graph.

I have followed steps from Olga’s post but to do that I needed access to SAP Netweaver AS 7.51 system. If you have access to system then it’s fine if not you can follow steps from Open SAP course ‘Extending SAP S/4HANA with SAP HANA Cloud Platform’ available at this link.

I am myself not a basis person but the steps to install your own SAP Netweaver AS ABAP 7.51 innovation package defined in above mentioned link are very detailed and straight forward. Once you have installed the system in virtual box, you will end up with a virtual machine box as below. However depending on when you decide to take snapshots of your virtual machine, your screen-shot may vary.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

In below screen-shot you can see I have started my virtual machine.

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Once you have finished up with Olga’s blog you can see SAPUI5 application installed on your own SAP Netweaver AS 7.51 system. Here is how my application looks like:

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

Time to launch your application and feed some data as mentioned in above blog. I have created a video recording which shows data being sent to UI5 application in real time:


Result B:

SAP NetWeaver, SAP ABAP Tutorials and Materials, SAP ABAP Guides, SAP ABAP Learning, SAP ABAP Certifications

2 comments: