openSAP Extending SAP S/4HANA with SAP HANA Cloud …

23
openSAP Extending SAP S/4HANA with SAP HANA Cloud Platform Week 5 Unit 1 00:00:12 Hello, and welcome to the openSAP course "Extending SAP S/4HANA with the SAP HANA Cloud Platform". My name is Thomas, and in Week 5 we will now create another extension on the SAP HANA Cloud Platform. 00:00:25 In Week 5, Unit 1, I will again help you to understand the challenge and why we need that extension. The extension will be an IoT (Internet of Things) extension let's see why we need that and understand the challenge for this. 00:00:40 So let's remember again a long time ago in the first week the initial challenge we gave to Peter Procurement. So Peter Procurement is a procurement manager, 00:00:50 and he has the challenge to reduce the variety of IT equipment to reduce the IT support costs. So far we have focused on identifying equipment by looking at the rating, satisfaction, or order numbers, 00:01:04 so looking at the data we already have and finding out if there's an indication that we could drop a certain device. But there's another challenge that we cannot solve like this because we simply don't have the data. 00:01:15 And this is finding out whether the reason for a defective item of IT equipment is actually bad product quality or whether it is inappropriate handling. 00:01:23 This is useful to know because if it is inappropriate handling, we can do something about it, maybe in our own company. If it is inappropriate product quality, we can decide to drop the product from the catalog because it has insufficient quality. 00:01:37 So the challenge is to find this out. Now for this partner that is going to implement the extension, the assumption is that 00:01:46 there could be something like inappropriate handling of the equipment by employees, and we can detect that. We can detect this by collecting damage data from sensors attached to the device. 00:01:59 And we could hand out the equipment to employees and attach such a sensor and find out how the equipment was treated. 00:02:06 So for this, the partner decides to build two extensions that we will now create this week: first of all, an Internet of Things extension that will provide precisely such sensors and connect such sensors to the equipment, 00:02:19 and secondly a mobile equipment tracker that will allow it to very easily find out for each piece of equipment whether it has actually been handled appropriately. 00:02:26 So I go to the device and scan it and find out whether it has been damaged by, for instance, dropping it. The architecture that we will follow here is now a combination of what we have previously learned. 00:02:39 So it will be the hub architecture that is integrating various data sources coming out from the data that is replicated and from API calls to the IoT service. 00:02:49 So the pattern we will now focus on is, first of all, there will again be the same data that we have already replicated from the SAP S/4HANA system. 00:02:58 Here the SAP Landscape Transformation Replication Server in the HANA in the cloud. We already did this last week, so we don't need to do it again. 00:03:08 This whole replication shop should still be running and should provide the latest and greatest data. Now what comes on top is that we will have another service that will also contribute data to this database,

Transcript of openSAP Extending SAP S/4HANA with SAP HANA Cloud …

Page 1: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

openSAP Extending SAP S/4HANA with SAP HANA Cloud Platform Week 5 Unit 1

00:00:12 Hello, and welcome to the openSAP course "Extending SAP S/4HANA with the SAP HANA Cloud Platform". My name is Thomas, and in Week 5 we will now create another extension on the SAP HANA Cloud Platform.

00:00:25 In Week 5, Unit 1, I will again help you to understand the challenge and why we need that extension. The extension will be an IoT (Internet of Things) extension – let's see why we need that and understand the challenge for this.

00:00:40 So let's remember again – a long time ago in the first week – the initial challenge we gave to Peter Procurement. So Peter Procurement is a procurement manager,

00:00:50 and he has the challenge to reduce the variety of IT equipment to reduce the IT support costs. So far we have focused on identifying equipment by looking at the rating, satisfaction, or order numbers,

00:01:04 so looking at the data we already have and finding out if there's an indication that we could drop a certain device. But there's another challenge that we cannot solve like this because we simply don't have the data.

00:01:15 And this is finding out whether the reason for a defective item of IT equipment is actually bad product quality or whether it is inappropriate handling.

00:01:23 This is useful to know because if it is inappropriate handling, we can do something about it, maybe in our own company. If it is inappropriate product quality, we can decide to drop the product from the catalog because it has insufficient quality.

00:01:37 So the challenge is to find this out. Now for this partner that is going to implement the extension, the assumption is that

00:01:46 there could be something like inappropriate handling of the equipment by employees, and we can detect that. We can detect this by collecting damage data from sensors attached to the device.

00:01:59 And we could hand out the equipment to employees and attach such a sensor and find out how the equipment was treated.

00:02:06 So for this, the partner decides to build two extensions that we will now create this week: first of all, an Internet of Things extension that will provide precisely such sensors and connect such sensors to the equipment,

00:02:19 and secondly a mobile equipment tracker that will allow it to very easily find out for each piece of equipment whether it has actually been handled appropriately.

00:02:26 So I go to the device and scan it and find out whether it has been damaged by, for instance, dropping it. The architecture that we will follow here is now a combination of what we have previously learned.

00:02:39 So it will be the hub architecture that is integrating various data sources coming out from the data that is replicated and from API calls to the IoT service.

00:02:49 So the pattern we will now focus on is, first of all, there will again be the same data that we have already replicated from the SAP S/4HANA system.

00:02:58 Here the SAP Landscape Transformation Replication Server in the HANA in the cloud. We already did this last week, so we don't need to do it again.

00:03:08 This whole replication shop should still be running and should provide the latest and greatest data. Now what comes on top is that we will have another service that will also contribute data to this database,

Page 2: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

2

00:03:20 and that will be sensor data coming from acceleration meters attached to the device. So meaning we have sensor data and the data out of the SAP S/4HANA back end in this HANA.

00:03:32 Based on this, we will now create an extension. First of all, this extension will manage the process to attach a device to certain equipment

00:03:41 and will bring together these two worlds that we have. And secondly, it will allow us to access an API that gives us all the information that we require.

00:03:50 So has a certain product been damaged? Is a certain product equipped with a device? And such things. To go through this process, we don't need to go through the prepare phase once more because we have already done that.

00:04:03 We have set up the replication, and we have the tables in the HANA in the cloud database. What we still need to do is set up the IoT services.

00:04:13 So we need to set them up, set their device types, message types, bind them to a database so that it will write the data there. And we again need to provide a set of destinations to allow working with these services and with the data.

00:04:26 If we have done this in the integration phase, in the extension phase we can then start our normal development tools again and develop an application.

00:04:36 This time we will use a Java application. So in fact, there will not only be a UI, but the hub itself will be implemented in Java

00:04:43 and will be, so to speak, a man in the middle between the database and various API calls and the UI and will provide a unique and simplified API that is suitable to serve the UI.

00:04:57 The roles that are required for that are again the HANA Cloud Platform administrator, which might also be the administrator for the IoT services, the application developer, who will create the hub application and set up the destinations for the hub application,

00:05:11 and finally, the developer of the UI, who will again build the Web front end on top of this API. So for this week, the challenge is that we want to collect damage data for equipment

00:05:22 to understand whether the equipment has been dropped. Or in other words: Has it been appropriately handled, or is bad product quality the reason why it is defective?

00:05:32 This will help us to understand whether we should drop the product from the list because of bad product quality. We will use the hub pattern for this, mixing up data and various data sources in one API.

00:05:44 We will integrate sensor data and back-end data for this. And in the end, again, a lot of roles and tools will be involved that we will use in the course of this week.

00:05:53 Thanks.

Page 3: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

3

Week 5 Unit 2

00:00:12 Hello, and welcome to the openSAP course "Extending SAP S/4HANA with the SAP HANA Cloud Platform". I'm Thomas, and in Week 5 we will create an IoT extension.

00:00:22 In Week 5, Unit 2 we will finally create the IoT service and set it up and connect first devices to that. So in Week 5 for creating an IoT extension, and we are in the second unit to set up the IoT service and connect devices.

00:00:39 In the overall picture, this means we are now up to setting up the messages that our IoT service should actually receive and the device types that are receiving these messages.

00:00:49 For this, we will also register a typical sensor device and test it a bit. We will do this with a local tool.

00:00:56 Finally, we will also create a destination to the IoT service so that in the next sessions we can use the API of the IoT service. The roles that will do this are again the HANA Cloud Platform administrator and the administrator of the IoT service.

00:01:12 That may be the same person or it could be different people. He will set up the IoT service and do the respective configurations.

00:01:20 Now let's do that practically. For this I will again wear my hard hat.

00:01:28 So, the starting point is the cockpit. You should already have opened the cockpit.

00:01:35 And should have a link from the previous sessions, so I will open it. It will probably ask you for a login.

00:01:43 And in the cockpit, we will again go to the Services section. The Services section is here.

00:01:50 And in the Services section, we will also find the IoT service. So if you go to the search and simply enter "iot",

00:02:01 there is the IoT service. The service is not yet enabled – as always – so we will enable it with our helpful Enable button.

00:02:15 It will take some time, and then it will be available. The next thing is that we need to configure this service.

00:02:22 So we need to go to this link here... and we will need to give roles to the user, so we go to Roles...

00:02:43 and there is an IoT user. Look here – there is the user already assigned.

00:02:47 If that is not the case, please do so. Now the next thing to do is we will open the service cockpit, so we go back to the service cockpit...

00:02:57 and we'll open it... by choosing Go to Service.

00:03:05 We'll now open a new page, and there are various options.

00:03:09 Here we can maintain the message types that could be received, the device types that could send messages, and devices based on that. But for now the most important part is that we also need to deploy the Message Management Service down here.

00:03:24 This is a component that will be put in your account and will then take care of receiving the data and putting it in a database of your choice. So here we choose Deploy the Message Management Service,

00:03:34 and we see it automatically puts in the account details and just asks for your password. This is required because it will now deploy the respective component as a Java application, so let's enter a password...

00:03:51 and press the Deploy button... yes, we're perfectly fine with everything...

00:04:04 So it will now take a bit of time until this component is deployed... and running...

00:04:19 Okay, there is a success message. And what is very good is that there is a link to the application that we want to go to – let's open this link.

00:04:28 This is exactly where we head to. And you will see that there is an application deployed in the dashboard...

00:04:37 that's about to start... While we are waiting for it to start, let's go back to the services cockpit.

Page 4: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

4

00:04:47 and actually save a link to the IoT services. So here let's go to the favorites and save the service cockpit to the Bookmarks bar.

00:04:57 Okay. We need it in the next steps.

00:05:02 Let's go back, let's see...

00:05:08 Okay, the iotmms service is now started. Before we can access it, we again need to make sure that we have the appropriate permissions.

00:05:16 So what we do for this iotmms service is again go to Configuration... Ah, no, we go to Security, and then we go to Roles.

00:05:30 And here we have another user, and we need to give this user as well. As always, we can get our user ID here from this icon.

00:05:39 Grab this one. And we can assign this.

00:05:49 Okay. Now we are ready to open the service.

00:05:54 So we can go back to the overview, and let's open that.

00:06:06 We are often told that this user is allowed to access this, and now we can start to work our magic. The first thing that we want to do actually is to have another bookmark for this, so let's put the bookmark there.

00:06:22 And now let's continue. What we now need to do is bring devices that can receive data.

00:06:31 So we click this link, View Registered Devices And Device Types, which will again bring us to the IoT service cockpit, and now let's start with the device types and message types.

00:06:43 Let's first create a message type. We use the "+" sign down here.

00:06:51 And now we need to provide a name. As we are essentially looking for data our device will be dropped, let's call it AccelerationMessageType

00:07:00 – "AccelerationMessageType" – because we want to have acceleration data.

00:07:07 This is also very convenient because most of your phones actually have such a sensor. We will have a timestamp that's already defined, but also more fields.

00:07:16 We'll have an acceleration for the X axis... an acceleration for the Y axis... and an acceleration for the Z axis. So we measure whether the device is dropping in any direction, and now we create that.

00:07:36 Here, with this button. Good, now we have a message type with these fields.

00:07:45 The next thing is that we will go back and create a device type that receives this. So we go to Device Types...

00:07:55 and again create a new device... We now call this "AccelerationSensorDeviceType" – see.

00:08:17 And we say it has a message type. This is "AccelerationMessageType",

00:08:25 and this should be sent from the device, so it will be sent from the device to the service. We create that.

00:08:34 Okay, now we have these two prerequisites and we can actually create the device. There are various ways to do this.

00:08:41 One is also to register it here directly and create a new device here, so again with the "+" button. We add a device and we call it "AccelerationSensor...",

00:08:57 or let's make it simple: "Sensor01" – there could be multiple sensors. It's an "AccelerationSensorDeviceType",

00:09:07 and we create that. Okay.

00:09:13 Now you see there is something with the token – let's go back to this a bit later. Good, what we have now created...

00:09:21 IT services are running, we have one message type, one device type, and one device – now we could send data. Now to keep it simple and for the purpose of this course, I will not connect a real sensor now because you may not have it at home,

00:09:34 but what you have at home is the Postman that you installed in the first week – it will probably be in here, in Apps. And there is something called "Postman" that you installed hopefully in the first week.

Page 5: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

5

00:09:49 And Postman allows us to send HTTP requests. To make it convenient, we have provided a helper for you,

00:09:57 so if you go to the environment here at the top and then this wheel, manage the environment,

00:10:06 we go to Import, we choose a file,

00:10:12 and then we have here for download... Ah, where is it?

00:10:25 Here – "IoT Sensor Environment.json". Open that up.

00:10:33 This sensor environment is used to create multiple post requests. You can configure it, you click on it, and now you need to bring in certain data.

00:10:43 So the HANA Cloud Platform user ID – we again know how to get this. We go to the cockpit... and fetch it from here.

00:10:56 So this is the user ID, and we put it here.

00:11:07 Let me just check whether I've copied everything.

00:11:13 Then the next thing is a message type ID. So the message type comes from the ID for IoT Services, so let's go here, into the IoT Services Cockpit.

00:11:24 Let's refresh. And there are the message types.

00:11:32 And there I have an ID – it's this one. So let's copy this.

00:11:46 Okay, let's again compare them to see whether it's the full thing. Okay, now it wants a device.

00:11:56 So we can also get the device there – remember we have a device here. It's "Sensor01".

00:12:05 And this is the ID of the device. Let's copy this into here.

00:12:19 And finally it wants an access token – so it's quite secure, not a service that can simply be called without authentication. So for this device we go to the Authentication

00:12:32 and here you can generate a token, and this token is what it expects – so this here.

00:12:44 Okay, let's put this token here... and update that. Now check again.

00:12:56 We have a device token that should serve as authentication – it's this one here. We have a device ID... that's this one.

00:13:13 And we have a message type... that we get from the message. And that is this here.

00:13:24 Good, now we need the messages to send. So first of all, we now set this environment.

00:13:35 Now we import something more – the messages. So we again choose a file here – we choose import, choose a file, now we choose "IoT Sensor Messages.json".

00:13:51 And we see there are two messages now that we provide: One has low acceleration, which is considered "safe" so to speak,

00:13:58 and one has high acceleration, which is considered as "potential damage". So let's send "Low" – we simply choose it and send it.

00:14:11 And we can now see the response and what's sent and how it's built up. So it's sent.

00:14:21 And let's send one "Damage" – so use this and use "Send". Now we have sent three messages already.

00:14:31 Where can we find these messages? Let's go back... and we go here to this "Send and view messages..." tab.

00:14:42 That is pointing back to the MMS service, and here we can display stored messages. So this table with the rather cryptic name is the message table,

00:14:56 and you see there that we have various messages. Here with the acceleration data.

00:15:03 Okay, nice. Now we have basically the capability to receive data.

00:15:08 You can also connect other devices to that. Now the last thing remaining is that we also want to provide the API to access the service.

00:15:16 So for this, we go back to the cockpit again and go to the destination tab, where we provide a link to the IoT service, or a destination to the IoT service.

00:15:28 So here we again go to "Connectivity", "Destinations"... and we again import a destination that we have prepared.

Page 6: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

6

00:15:42 So we import that. It's in the "destinations" folder.

00:15:49 And this one is pointing to the IoT service. Now the IoT service is authenticated, so we again need to provide our user.

00:15:59 So again, this user – maybe you know it off by heart in the meantime, or have put it onto the clipboard and it's somewhere else. And the user's password...

00:16:18 Another thing that needs to be done: This link, this URL also contains your trial user, so we fix this and put your trial user there.

00:16:30 And this is the link to the API. We can save that.

00:16:38 And here we now have the IoT service available. Now you might ask: "Where do I get this link from? Why might I know it?"

00:16:47 For this, you can get API documentation for the IoT service. You'll find it in the help.

00:17:00 There's the IoT service. And there's the Remote Device Management Service API, the Message Management Service

00:17:08 and here you get all the information on how to use this device. So for this unit, we are done.

00:17:13 Now we basically have the IoT service set up to receive data. Thank you.

Page 7: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

7

Week 5 Unit 3

00:00:12 Hello, and welcome to the openSAP course "Extending SAP S/4HANA with the SAP HANA Cloud Platform". I'm Thomas, and I'm guiding you through Week 5 to create an IoT extension.

00:00:23 In Week 5, Unit 3, we will now use the IoT services that we configured in the last unit and actually write the data to the SAP HANA in the cloud.

00:00:33 So it's Week 5, the IoT extension, and we will now set up the IoT service so it will write the data in our SAP HANA in the cloud.

00:00:43 Mind you, so far we have set up the service and it's writing the data somewhere. So we have not looked where the data is – we know that it's ending up somewhere.

00:00:50 But now we want to make sure that the data goes to the SAP HANA in the cloud because this is where we can get it, analyze it, and combine it together with the SAP S/4HANA data that we replicated.

00:01:02 So for this, we will now set up some additional tweaks in the IoT service. This will be done by the SAP HANA Cloud Platform administrator or the SAP IoT service administrator.

00:01:15 So either one needs to have access to the service and provide some administrative settings. Now let's do this live.

00:01:24 Here comes the hard hat – now we are ready. And as always, we will go to the browser first.

00:01:33 So what we need to make sure of in this unit is that the HANA is actually running. Let's not forget that we have a time-shared HANA that is shut down after a certain time,

00:01:42 so we go to the cockpit and first check whether the HANA is actually up and running. If not, we need to start it.

00:01:50 This is done here in "Persistence", "Database & Schemas".

00:01:59 There is a "hana", and by now we also see these other schemas, and we could have a suspicion as to where the data has actually gone.

00:02:06 Now let's go to the "hana". And my "hana" here has started.

00:02:14 Yours might have as well, but if not, press the "Start" button. Now let's go.

00:02:19 What do we need to do? We need to go to "Message Management", so we have already put this link here.

00:02:28 If you don't find it, you will find it via the Java application. So let's do this once more.

00:02:39 Here in "Java Applications"... and there's an "iotmms".

00:02:47 Here's also the trusty "helloworld" that we deployed in a previous action. So let's open that.

00:02:57 Let's open this link, and we will end up exactly where this link would have been. Now what we need to do is configure processing for the service mappings, and here we can put the database.

00:03:09 However, the whole thing needs to be done when the application has a binding to the database. And to change this binding, we first need to restart it.

00:03:20 So let's go back... and let's stop this application,

00:03:26 and then edit its binding. We don't need to wait for it to stop – we can immediately go to "Configuration",

00:03:35 "Data Source Bindings", and we see that there is a certain binding in place that is not pointing to our HANA but somewhere else.

00:03:44 Ah! So our assumption was right – this seems to be the place where the data goes. Let's remove this

00:03:51 with the nice trash bin... Yes, we want to remove this.

00:03:58 And let's create a new binding with this button here – "New Binding". Now we have a choice.

00:04:06 The data source we simply leave as "<default>". The schema we put in the HANA – that's already there.

Page 8: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

8

00:04:13 And we need a database user for the HANA, and this is the one we already used before, so it's this one. You probably also used that.

00:04:21 Including its password. Now let's save it.

00:04:28 And now we have set up the binding of this service to this database, so from now on, the data will be written there. Let's go back to the overview

00:04:41 and start the service so that it will start using the database. While we wait for it to start, let's bring up the HANA Cloud Platform tools.

00:04:53 So here I will start Eclipse... and connect my HANA tools to my HANA to check what has happened in this HANA. I will go to the... ah, we'll automatically connect... I will go to "SAP HANA Development"...

00:05:19 and will go to "Systems"... and in "Systems" I have here my "Catalog"...

00:05:26 and can check what has happened in my catalog. I can open it, see the tables.

00:05:38 And there are no tables in it. Okay, this is no surprise.

00:05:44 We have not configured anything yet, so let's go and see if the application has started up...

00:06:43 So the application has started again and it is now using the binding to the new database. Let's open the cockpit once more... get a fresh login...

00:06:55 and now we can do some configurations. We do this here in "Configure Processing Service Mappings", where we can say what should happen with a certain message.

00:07:08 We can add a mapping here... and now it wants to know what device type ID and what message type ID will be used.

00:07:17 So we can go to our IoT Services Cockpit either by navigating back – I now have the link here already on my desk, so let's go for that. And what we now need is exactly here, hidden in these items.

00:07:32 Let's see again – the "Device Type ID", okay, so here we have the device type. We choose our AccelerationSensorDeviceType, and it has an ID – let's get that... and put it here.

00:07:52 And a "Message Type ID". So if we navigate back,

00:07:57 here we see "Message Types", and this also has an ID.

00:08:06 Now maybe you're a bit confused by the fact that we're using two cockpits here, so let me emphasize this again. There are basically two cockpits:

00:08:14 one IoT cockpit for the MMS, for Message Management, and the other one for Device Management, and we are switching between these.

00:08:23 So this one is the Device Management, or Internet of Things Services Cockpit, and the other one is the Message Management Services Cockpit.

00:08:34 So now we have copied these ideas, let's add some processing service, which we do here. And there are various services.

00:08:42 What we want to do is "sql" because our database likes it. And now we need to do some settings.

00:08:49 So first of all, we want to write all kinds of master data into it. You see here that there are some standard columns – we want to have them.

00:08:57 And we need a schema name, so the schema of our user is simply "ACME". And we want to have a special table, and we want to know what the table is, and we call it "T_IOT_MESSAGE".

00:09:11 So we tell them: Please put your data in this schema in this table. Now we need to navigate back here...

00:09:20 and create this mapping, again with this button. Now we can start testing it again.

00:09:29 But let's see first what's going on in the HANA. So I'll go back to the Eclipse tooling and do a refresh on the tables.

00:09:41 Ah, and look – there are certain IoT tables suddenly popping up, so it seems to use it. Now let's send some messages and see what happens.

00:09:49 For this, we again use our Postman tooling, so we go to Google Chrome, go to "Apps", and open Postman,

Page 9: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

9

00:10:01 and there we already set everything up in the last unit, so we still have our "IoT Sensor Environment", and here we have our "IoT Sensor Messages".

00:10:12 Let's send a low acceleration... maybe twice...

00:10:24 and let's send a high acceleration. And now let's see if there's some data in the HANA actually, so we go back to Eclipse

00:10:38 and do a refresh on the tables. Aha, and there's even a new table now called "T_IOT_MESSAGE" as we defined it.

00:10:50 If we now do a context click and open the content, we see these three messages we sent, and it's two messages with a rather low acceleration and one with a bigger one.

00:11:04 This means we are now able to send and combine data in our HANA. We will start doing this in our next unit.

00:11:11 Thank you.

Page 10: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

10

Week 5 Unit 4

00:00:12 Hello, and welcome to the openSAP course "Extending SAP S/4HANA with the SAP HANA Cloud Platform". I'm Thomas, and in Week 5 we will continue to work together on the IoT extension.

00:00:23 In Week 5, Unit 4, we will now consume the data that we put in the HANA in the previous sections from a Java hub application. So it's Week 5, IoT Extension, and we are in Unit 4, Consuming Data from SAP HANA with Java.

00:00:40 Now let's understand what we need to do. We have now put all kinds of data into the SAP HANA in the cloud:

00:00:46 the data that is replicated from the back end, the data that is coming from the IoT services. Now we need to start consuming the data,

00:00:54 meaning that we now create an application that will give an API based on this data that is consumable by a UI. This will be done by the role of an application developer.

00:01:05 So it's not yet about UI development. It's now really about a kind of back end in the cloud that will turn this data, tables, and views into an API that can be used for the UI.

00:01:16 As this is quite a complex thing, the application developer and the UI developer need to discuss very carefully what the desired API is, or what is required.

00:01:25 Let's do this discussion a bit on the data model now in this section here. Now, what do we have so far in the HANA?

00:01:33 We have replicated data, so for our purposes now we need the sales order data, the item data, the product data, and the text data that will translate products into nice names.

00:01:45 Also, we have data coming from the IoT services – the messages coming from the sensors. What do we do with that now?

00:01:54 The first thing we need to do when creating such an extension is find out whether there is a certain item of equipment attached to a certain device.

00:02:03 For this we create a new table. This table will link a device for which IoT messages are collected to an item of equipment

00:02:11 that will later on be related to something that was ordered. The next thing we need to understand is what devices are actually available out there for recording,

00:02:22 so that we can attach them, so that a UI developer can provide an application that attaches a sensor to equipment, and so that we can find out what data is there for the equipment.

00:02:34 For this we create another table. Then we can create our first view out of these

00:02:40 This view will tell us which devices are still available, meaning they are registered in the IoT services but are not yet used to track certain equipment.

00:02:50 And so that we know that these devices can actually be used to track equipment – they are still free and can still be connected. We should not use them for any other devices that are already used.

00:03:02 Now the next thing is we want to use the IoT messages, and we want to relate the measures that we have in these messages with a device and with an item of equipment,

00:03:14 and this is done in the view "DAMAGE_DATA". The "DAMAGE_DATA" view will collect this, calculate a kind of damage prediction – if there are certain measurements,

00:03:24 there might be damage – and will relate this to certain equipment that is attached to a certain device. Now we know the damage per item of equipment.

00:03:34 Now another thing is the equipment itself needs to be related to something we have in the back So the "view equipment" will now bring together the information on what damage there is,

00:03:46 which device is attached to which equipment, or to the equipment here, and what order and which item position in this order and which product the equipment is.

00:03:57 So now we can answer the question: In this order a product was ordered, it is an item of equipment and it has a certain device – did this device capture any damage or not?

Page 11: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

11

00:04:07 Finally, there is another view – "SALES_ORDER" – that will simply give an overview of all sales orders that have been or are in the system

00:04:16 and that actually have some devices that are measuring equipment. With this view, we can find out whether tracking is actually active or not for a sales view.

00:04:27 So we can decide: Is there the need to track something because no single item of the order is tracked, or is there already something going on?

00:04:36 Good. This is quite an impressive data model, and this is all that the extension will do – now let's do that.

00:04:45 I will again go for my protective equipment because now it's getting really dangerous. As this is a Java application, we will now open Eclipse,

00:04:58 and in Eclipse we will first of all import a project that we have already prepared. And that will provide a first version of this hub that will just take care of the data model.

00:05:10 So we can now go to the Java perspective using this link – we enabled this perspective earlier. And we can now go here to "File" and "Import...".

00:05:27 And now we will again look for "maven" and go for an existing Maven project,

00:05:34 like we already did in Week 1 with the "helloworld". We will browse for such a Maven project.

00:05:43 And we will again find it in the files that you can download – it's in "week 5 - IoT", in "unit 4". There's "java".

00:05:53 We need to extract this. Ah, let me first extract that...

00:06:03 Now we have a folder. And this folder we can import.

00:06:08 Okay, open it. In the folder, we find this version 1 ("v1") of the

00:06:16 and we will add this to the "JAVA" working set. Just to structure the workspace a bit,

00:06:22 we choose the "JAVA" working set, and we finish this. And now, in the "JAVA" working set, a "hub-v1" project appears.

00:06:35 We will now build and deploy this, and while we deploy it, we will actually look at the source code a bit. So to build this, we will do as we did in the first week.

00:06:47 We will do a context click, go to "Run As",

00:06:53 and "Maven install". Now the console will show that something is going on and the build was a success.

00:07:04 And we will find in the "target" folder... a "hub.war", which we will now deploy.

00:07:12 We will do this deployment via the cockpit, so we will open the browser, and in the browser we will open the cockpit...

00:07:25 and in the cockpit we will create a new Java application. So we will navigate to "Java Applications".

00:07:35 We already have the "helloworld" from Week 1, the IoT service that we did this week, and we create a new application, so we choose "Deploy Application",

00:07:45 we look for this WAR file that we have built, we find it in "week 5 - IoT",

00:07:53 "unit 4". In this folder, in your workspace folder, so wherever you have put the project, in the "target" folder there is the "hub.war" file.

00:08:02 On my file system it's here – you may check in your Eclipse where you put the files. We open this,

00:08:10 we simply leave the name as "hub", and here we go for "Java Web Tomcat 8" – so we use the latest and greatest runtime.

00:08:18 So we deploy this, which now takes a bit of time...

00:08:28 And we will wait until it's processed. Now it offers to start it, but we don't want to do that – let's go to "Done", not "Start", because there's one important prerequisite.

00:08:40 This application still needs to be connected to the same database that we used for the other data. So we go here, click on the "hub" application,

00:08:54 and we go here to "Configuration", "Data Source Bindings".

00:09:00 And now we bind it to our HANA, where all the data is. So we choose "New Binding" here,

Page 12: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

12

00:09:10 we leave the data source default, we choose "hana", this is our database, and the user is the database user, so the "ACME" user with his password.

00:09:23 Save this. Good, and now we can start the application.

00:09:30 But before we do that, let's do the following. Let's go back to Eclipse, to "SAP HANA Development",

00:09:41 and connect to Eclipse to find out what's going on in Eclipse. So here we choose "Systems",

00:09:50 I connect to the HANA. Yes, the firewall is very active here.

00:09:57 This is my database password – it's asking me for it. Okay. And let's have a look at "Catalog".

00:10:06 So I go here to "Catalog", I go to my "ACME" schema, then "Tables", and "Views",

00:10:21 and there we see the tables of the IoT service, and there are no views in it. Let's remember this.

00:10:29 Now we go back and start the application. So we'll now go to "Overview",

00:10:39 and press "Start". Now this takes some time, so we can use this time to actually have a look at what is going on in this application.

00:10:49 So let's open Eclipse again, and let's go back to the Java perspective here, and have a look at the project.

00:11:01 So the project structure is like this. The "target" folder is the build folder for Maven, we have "Java Resources",

00:11:10 and then we have some folders, apparently we have some scripts here, meta information, so let's have a look at this.

00:11:20 Also, we have Web resources. So if you look here for the source,

00:11:27 there's also a "WEB-INF" folder... here. There – "index.html".

00:11:36 So you should know this – this is a standard servlet project so to speak. It has everything you require – the "web.xml", the web "resources". Let's have a look at this to find out what's going on.

00:11:52 So, in this view we see the following... Let's make it a bit... let's open this.

00:12:04 We have the following settings. Apart from some standard settings like what the name of this application is, what the welcome file is,

00:12:14 we also have a resource definition, and this resource definition is pointing to the default database that we have just bound with a binding. It's a default database, and it's an "... sql.DataSource".

00:12:26 Another thing is we have created a "listener", and this listener – the "jpa.dbsetup.DatabaseEntitySetup" – is waiting for the startup of the application,

00:12:36 and at the beginning, checking whether all data, tables, and views that it requires are there – the ones I just explained. If they are not there, it will take care of creating them.

00:12:47 Also, we have enabled login for this. We are now exposing data to the Internet, so we should have some kind of protection,

00:12:54 otherwise this application will basically blow the data onto the Internet. So here we have put "BASIC" just to have some mechanism in place.

00:13:03 In the source it looks like this. This is the resource definition.

00:13:09 This is the listener. Now let's have a look at this listener.

00:13:14 You find the listener here, in the "com.acme.s4ext.jpa.dbsetup". And this listener will basically just call the "DatabaseEntitySetup.java", which is this one.

00:13:28 And here it's getting interesting. In the "DatabaseEntitySetup.java", it will check whether certain databases are there already.

00:13:37 And create them. So what is interesting in this class is that there's a definition of what is expected and to be checked.

00:13:48 And this is a kind of helper class that says "look for these tables or views, and if they're not there, then supply them from these SQL scripts".

Page 13: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

13

00:13:59 And these you can find in the "resources" folder. So let's look here in the "resources" folder – "sqlscripts".

00:14:08 So this is something I cannot explain fully, but here you will find the SQL statements to create all these with some small comments.

00:14:20 So here we see we create a table for this, with certain fields – it's an easy one. Or for "IoT device" we also create a table, so these are the two tables – it's easy.

00:14:33 But now let's go to the "damage". It's a view, so we create a view.

00:14:40 We select items from the "EQUIPMENT2DEVICE" table, and we set items from the "IOT_MESSAGE" table,

00:14:50 and what you see is we do a kind of calculation and we say: Let's do a kind of calculation of all acceleration values along all the X, Y, and Z

00:15:02 and find out what the maximum is, and if the maximum is over a certain threshold, let's assume it could be damage.

00:15:08 This is not super nice, so usually you would do this as a setting, but as an example it's done here like this. Then you have the "V_EQUIPMENT".

00:15:20 You also see the status structure – now it's getting a bit more complex. The "V_FREE_DEVICE" is a simple view that will simply find out whether there's a device available.

00:15:33 And finally, the "V_SALES_ORDER". By the way, what you see in the "V_EQUIPMENT" and "V_SALES_ORDER", like in the picture,

00:15:40 is that we are using the replicated data here and taking some parts of it. And here, for instance, we take most parts of the replicated data from "SLT_REPLICATION"

00:15:52 and we will take some parts of the "T_EQUIPMENT2DEVICE" to find out whether something is actually registered.

00:16:00 Okay. Now, if these tables are created,

00:16:07 we will need a model to access them, here JPA. This model is basically defined in this folder, so you will also find a reflection of all that we have just seen in the real SQL statements here.

00:16:18 Let's go for a simple one. And you can have a look at the others yourself – here, the "FreeDevice" for instance.

00:16:25 It will, with a JPA annotation, declare that this is a table and its data model and setters and getters for all this that we require. As it's read only, this is only getters.

00:16:37 Basically, most of the things we are doing are read only – only the tables we create with this application actually have write permissions. Now the next thing is we will have a servlet that will show a bit of example data and we can see how it is consumed.

00:16:58 And this servlet – let's have a look here – basically shows how to get data with Java out of the HANA. This servlet is using an entity manager – so the normal means for a JPA – to get data out of the table.

00:17:16 It uses a primitive way of writing a bit of HTML5 to show something, and here you can see that it uses a factory to get an entity manager and try to connect it to the database,

00:17:28 and then read equipment and list equipment, so here the reading... is happening here, there's a query...

00:17:40 that is defined in the respective model. So we find it in the model, for instance for "SalesOrder" here,

00:17:50 you see there is this query, "select s from SalesOrder".

00:17:56 Okay. Now what we have in place is we have created the tables, the views,

00:18:01 we have a JPA model to consume it, we have some servlet that is creating an entity manager to consume it. Now what is still open is how the framework works, and what we have here...

00:18:13 As a framework we use EclipseLink, meaning we define that a certain framework should be used, and EclipseLink works with this "persistence.xml",

Page 14: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

14

00:18:23 so if we look here, we see definitions for all the models we have just seen, and the name, that the entity should be named "hub".

00:18:37 And as a last thing, we also have here a "pom.xml" file, the Maven file, which explains that we have a dependency to EclipseLink.

00:18:52 So look here – there is EclipseLink, we have this dependency, and we need to bring the library into there. So this is the basic structure – now let's have a look at the application.

00:19:02 First of all, let's have a look at the SAP HANA Database to see whether anything has happened, so I'll switch to the HANA perspective.

00:19:12 And here again, we have our tables and views. So let's do a refresh.

00:19:21 "Refresh" Look – two new tables have been created, which happened on startup.

00:19:32 And we have created a lot of views... which also happened on startup. Now let's have a look – we can now open the content for this.

00:19:42 For instance, let's look at the "SALES_ORDERS". "Open Content"

00:19:49 And you see we have working views. Now the last thing to show is that the application itself can actually consume it – so this is directly the HANA.

00:19:58 So we go back... to the cockpit... open this link of the view that is now running...

00:20:09 It requires a user, so this is again your trial user, and this is because we enabled the basic authentication

00:20:20 so that the data is not simply sitting on the Internet. And here we have our servlet: version 1, JPA.

00:20:35 In the JPA preview... we get the data with this ServletServ that we have just seen.

00:20:44 Good, now we have the data in Java. Now, in the next unit, we can continue to make it a service.

00:20:49 Thank you.

Page 15: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

15

Week 5 Unit 5

00:00:11 Hello, and welcome to the openSAP course "Extending SAP S/4HANA with the SAP HANA Cloud Platform". I'm Thomas, and in Week 5 I'm creating an IoT extension with you.

00:00:21 In this unit, Unit 5, we will now provide the data that we already have in Java as an OData service. So it's Week 5 about the IoT extension,

00:00:31 and it's Unit 5, providing the OData service in Java. In the last unit, we actually put the data in the HANA,

00:00:38 so we have the data from the IoT service, we have the data from the on-premise, and now we want to again enable the UI developer to simply consume a destination and call a REST API to develop a Web UI.

00:00:51 In the previous units, we have already seen that it's quite nice. The UI developer does not need to know where the data comes from and where it is fetched.

00:00:59 He just uses the API that is provided by the destination and builds his UI on top, and now we also want to do this using Java. There's another challenge that we need to solve.

00:01:11 Some tables are actually not filled with data at the moment because the data is coming from the IoT service but not written in the tables that we have provided to the IoT service.

00:01:21 So for this, for instance for the "T_IOT_DEVICE" table, the IoT service provides us with an API that can allow us to fetch devices. So on the one hand, we want to provide a RESTful server for the OData services,

00:01:37 but to fetch this, we want to provide a RESTful client to fetch the devices from the OData API of the IoT service. And these two things we will do in this unit.

00:01:50 This will be done by the developer who will create the next version of the hub application that will fetch the data from the IoT service and provide the data we have so far as OData services.

00:02:01 And that looks roughly like this. So we have several inbound and outbound services.

00:02:07 The inbound service is that we want to fetch the HCP IoT API to get the devices via a device synchronization task and put the results in the "IOT_DEVICE" table.

00:02:20 The next thing is that we want to have all the views and tables that we created in the last unit as OData services available for the UI developer. So we will use Apache Olingo for this, and we'll provide the respective entities simply as Web resources.

00:02:37 Now let's do that. Very dangerous, so there goes the hard hat.

00:02:44 We will start our journey in Eclipse because we will develop a Java application. And what's very important here: We're using the HANA heavily, so be reminded that you need to start the HANA if it's stopped.

00:03:00 So we have a timeshared HANA only for this trial, so you want to check whether the HANA is up and running, and start it now. My tooling is now actually connected to the HANA and it seems to be fine.

00:03:12 Now what we will do is import the next version of the Java project. So let's go here.

00:03:21 We already have the "helloworld" and the "hub" versions, so now let's bring the next one. So for this, again we can download the respective file, and we can actually unzip it, and then we can import this folder.

00:03:38 So let's go to "File", and "Import...".

00:03:44 Again, we want to have a Maven project. Now we need to find the folder.

00:03:51 I'm not sure where your files are sitting, mine are here in this week – "unit 5", "imports", "java", "hub-v2". Make sure that's version 2 – you also see it here: "hub-v2".

00:04:07 And we add it to the project – "Add project(s) to working set", "JAVA", to have some structure. We finalize this.

00:04:18 And here we now have another project. Again, it's a Maven project, so to get it running, we can actually do a context click, go to "Run

00:04:33 and say "Maven install". And this will now fetch the dependencies,

Page 16: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

16

00:04:40 and build the application. The build is successful, so we are happy, and in the "target" folder we find another WAR file.

00:04:51 So here is the WAR file that we will now use to replace the existing hub in the cockpit with the new version. So let's see.

00:05:02 For this we go to the browser and open the cockpit again. The link should be there from the previous units...

00:05:21 So now we go to Java applications, so you can either go here... or here... And we stop the existing hub.

00:05:34 So we go to the hub, and upload a new version.

00:05:41 We stop it, and as always, we don't need to wait for it to stop – we can immediately update it, so I'll click on "Update".

00:05:55 I go to "Browse...", and now we need to find the right targets.

00:06:00 Let's be very careful about this because the WAR file has the same name as the previous So now I have put my local files here in "unit 5", "imports", "java", "hub-v2".

00:06:14 And then you find the WAR file in the "target" folder, so it's the version 2 hub. Let's open this and update this.

00:06:28 Okay, it's done. So now let's start the application and then have a look at the project.

00:06:35 We start it. And let's go back to Eclipse and have a look.

00:06:42 Essentially, it is an evolution of the previous hub project, so we have the same structure. And you will find again in the "src", "main", "webapp", "WEB-INF" folder, the "web.xml". Let's start the journey there.

00:06:58 So in the "web.xml", we now have the previous settings, but also some new ones, so let's look at those. So the "display-name" is still the same, the "welcome-file-list", yes, it's still the same.

00:07:09 We have a resource definition, which is the same as the previous time. It is the name for the database.

00:07:15 So we still need that, obviously, but there's now a new resource definition. The new resource definition is a connectivity configuration,

00:07:23 meaning that we are now consuming in the application the connectivity service to connect to the IoT service API. And this is how the dependency goes into the Java application.

00:07:35 Then we have our "listener" section, and we have the "DatabaseEntitySetupOnStartListener", which we already know about, but now we have a new listener as well, and this is the "DeviceSynchronizationOnStartListener".

00:07:47 So this is the listener that will initially ensure that there is a regular job running so that we can fetch IoT devices. Let's have a look at this.

00:07:59 So we find the "Java Resources" here, and here we have this folder containing the package with IoT listener,

00:08:10 and this is the listener. And this listener will in the end do something very easy – it will create a polling.

00:08:20 It will create a scheduled job that will poll in a certain timeframe for new IoT devices. That is not really recommended, but for this simple project, it is a good starting point.

00:08:31 There are other, better ways of providing this. But for now we have gone for this simple poll edge second and called the API.

00:08:40 Now, for the API, for the task itself, it's a "DeviceSynchronizationTask". So let's look at this one.

00:08:48 The "DeviceSynchronizationTask" will basically call for devices, and then try to write them in the database.

00:08:57 So here is the client, the REST client that will actually call the IoT API. Let's have a look here.

00:09:09 And this now is a bit of a plumbing job to open a connection to the IoT REST API and fetch the data. What you see is that we have here a destination actually referred with an API.

Page 17: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

17

00:09:21 So this destination actually needs to be already there in the system. And, as you may remember, in previous units when we set up the IoT service, we provided this destination.

00:09:31 So this is a recommended pattern, that the person or colleague who is creating or providing a certain API also provides a destination to access it.

00:09:40 If you create an OData API, you provide a destination to access it. If you provide a service, you provide a destination to access it.

00:09:47 This is simply because the provider knows best how the API is working, what authentication mechanisms are working and this kind of thing. So here we have already provided this destination and can use it, and can fetch the data from the IoT.

00:10:04 So now let's have a look. In the cockpit, the application has already started.

00:10:11 Let's maybe look here in "Destinations" to see if we find this destination I just spoke of. So if we find it here in "Connectivity" and "Destinations".

00:10:25 And this is the IoT Internet destination we provided earlier. Now the result of this, as the application is now started, is that we should now have devices in our table.

00:10:36 Let's go for that. The simple check is to go to "SAP HANA Development",

00:10:45 and go to "Systems", and have a look in the table.

00:10:51 So we go to "Catalog", there is the table in this schema,

00:10:59 it's "T_IOT_DEVICE", let's open the data,

00:11:05 ah yes, and there is a sensor replicated, so the job is up and running and working and actually fetching data – very nice. Let's go back to the "web.xml".

00:11:17 There's something else in the "web.xml", and there is a servlet mapped here. The interesting part is in the previous unit, we didn't have this for this JPA servlet that we used, because there we used simple annotations.

00:11:30 So directly in the source code we described that there is a class that should serve as a servlet. But here we don't do that, and the reason is that we are not implementing the servlet.

00:11:42 We are using a framework, so we use Apache CXF as the framework to give us an out-of-the- box servlet. But what is this?

00:11:52 If you look for the parameters that we give, this is a servlet that is using the Apache Olingo framework to provide an OData service. So we tell Apache CXF: Please use Apache Olingo to provide an OData service.

00:12:07 And as the next parameter, we then tell Olingo: Please use this kind of class, this factory to provide the data. So the only class we actually need to implement all this logic to bring the whole OData

00:12:19 service out there based on all the JPA entities we have is this one. This is quite neat – let's have a look at this class.

00:12:28 So if you look at this class, you will find it... ah, we need to go to the Java perspective. So we go to the Java perspective.

00:12:40 And then here, under the OData, we find exactly this class, and that's all.

00:12:49 All this, this is the whole source code. We will get an entity manager for the JPA

00:12:57 that brings all the data with us that we created in the previous unit. And then we connect it to Olingo and – voilà – we have all services. Now this is very easy.

00:13:08 So now we have all the bits and pieces in place. We have an IoT service that fetches the data, the data is in the table,

00:13:15 it's a REST client to the IoT REST API, and we have a REST server provided by the Olingo and Apache CXF framework to get the data out as a data service.

00:13:26 Now let's have a look. In the cockpit, the application is running.

00:13:31 We go again to "Java Applications", we have the "hub" application,

00:13:44 we can open the "hub" application, and now it asks us for a password.

00:13:49 Again, it's our normal password for our user here, so let's go here, here is the user. You know the trick already.

Page 18: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

18

00:14:01 We copy that. Password.

00:14:08 We protected this so that the data is not simply in the cloud, and here you see some friendly starter that gives you access to the OData service.

00:14:16 So here, with this URL, you see the list of all services. Aha, these look familiar.

00:14:25 "Equipments", "SalesOrders", everything we wanted to have. Let's look at the data.

00:14:31 We also have some metadata that describes the data types, so now you see what is delivered by these services. You can do this and look at this, and we can also look at the services, so let's look at the devices, for instance.

00:14:46 So there are IoT devices. It's the one device that we have actually replicated.

00:14:52 Let's do the next question. Which device is free?

00:14:56 It should be... and exactly this device is free – it's not yet used, so to speak. Is there any damage already?

00:15:04 Hmm, not yet – I mean, we have not yet recorded too much with these devices. And so on. Let's go for a bit more data – the SalesOrders.

00:15:15 Ah, there comes the data. So, in short, our OData service is working.

00:15:22 Now what we want to do is the following... I'll now close all this testing. First of all, we can create a link to the hub.

00:15:31 That's always very nice. And the next thing is, we now need to do the final step – provide a destination to the hub so that it can be used.

00:15:42 And that destination needs to go to this OData service, so let's open this once more. And we need this link...

00:15:53 where the service needs to go to. Now, the destination is as always created in the cockpit, so let's go to the cockpit.

00:16:03 Go to the destination. Here we go to "Connectivity", "Destinations",

00:16:15 and we can again import one, because I have prepared one. So import this.

00:16:25 It's in the "imports" folder, "destinations", pointing to the hub, it's "hub-internet-http",

00:16:33 we open that, and now let's see. It's a hub destination going to this hub service.

00:16:43 Here we need to provide the link This is the link that I've just fetched, so let's have a look, I'll copy this.

00:16:51 This is what you have here – this link. Then again it wants to have a user because we need to authenticate, and the password for the user...

00:17:03 In this case, we can use the default JDK truststore, and we save this. Now, actually, the hub developer has provided the first API to the UI developer.

00:17:17 We could now test whether this API is available in the Web IDE, so we go to the Web IDE – we already have it available here. We open it up,

00:17:31 and we can now maybe start a new project from a template. It doesn't matter too much.

00:17:38 I'm just choosing one. I will call it "HUB".

00:17:43 We just want to check whether we could actually continue now. There's a service URL.

00:17:51 Here are the hub services. And there they are, so now we are ready to go in the UI.

00:18:00 Good, and this we will do in the next unit. Thank you very much.

Page 19: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

19

Week 5 Unit 6

00:00:11 Hello, and welcome to the openSAP course "Extending SAP S/4HANA with the SAP HANA Cloud Platform". I'm Thomas, and we are approaching the end of Week 5 with Unit 6, where we will finally provide the UI for the IoT extension.

00:00:26 So it's about the IoT extension in Week 5, and it's about the last unit in this, Unit 6, for the user interface. So we have again, as in the previous units, the situation that we have in the extend phase –

00:00:39 we are ready to support the UI developer to simply develop his UI and put it in the Fiori launchpad. All services, all data, all APIs – everything has been prepared and is reachable via a destination.

00:00:51 In this week, we have actually created a hub application that combines replicated data and data we got from the IoT service, and that would be fetched from the IoT service via the REST API.

00:01:02 So different sources integrated behind one API that we now provide to an OData interface that can be easily consumed. The OData interface is available in the Web UI and can then be used for the application.

00:01:17 This again is a task for the front-end developer, who will work his magic in the Web IDE, and we will again do this live here. So there goes the hard hat, and now let's fire up the browser.

00:01:32 So as always, the development of the front-end developer will happen in the Web IDE. So with the browser we go to the Web IDE – we have the link from previous units.

00:01:46 And in the Web IDE, we already have our previous projects – the "manageproducts" and the "productanalytics". Now we will import two more projects – let's get them.

00:02:00 "File", "Import"... Let's use "Workspace" and then go to "File", "Import", "From File System",

00:02:09 and we have provided two applications for you, which we will now look at. They will be in the IoT week, "unit 6", "imports", "html5",

00:02:21 and first of all it's the "sensorworklist.zip" – let's open this. Let's put it in the "sensorworklist" folder.

00:02:31 And let's first start it to get an impression, and then let's go through the code a bit. So it's started, choosing the project, running it...

00:02:46 And what we see is an empty screen, so this screen here has the purpose of linking sensor devices to equipment. So we have provided all the data and all the services – let's see how we can do that.

00:02:58 There is this small register button here... that will bring us a menu. The first step is that we need to find a product to attach this device sensor to, so we will choose a sales order.

00:03:15 Let's simply take the first one and now we go to step 2. Then it will fetch all the products for this sales order, so you see all this has been ordered with the sales order.

00:03:26 Let's go for the notebook because it's a good candidate for such a device, and go to step 3. Now it will tell us all the sensors that are still available so that we can choose it – so there's just one, we created just one.

00:03:43 Let's review that. Now we have this sales order with this product and this sensor.

00:03:52 Press the "Register" button and we have an entry, and this already even has damage.

00:04:00 Let's now register a second one following the same process.

00:04:07 So here we have this sales order – let's use the same one. Go to step 2.

00:04:14 Now use the other notebook. Step 3.

00:04:17 And there is no sensor device left now. So the free devices are empty, we cannot attach another one, but we could create a new sensor device,

00:04:26 so let's go to the IoT Services Cockpit... and simply create a new one. So we are exactly in this cockpit to create a new sensor – I will press the "+" button here,

00:04:40 the "Sensor02", it's also an acceleration sensor device, and I create this.

Page 20: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

20

00:04:53 We now have two sensors available. And if I go back to this application,

00:05:00 and press the refresh button here, ah, there's the second sensor.

00:05:06 So we review that – we are satisfied, and we register that. And you see that as it's a completely new sensor that has no data yet, we get different responses.

00:05:17 So here, for the first one where yesterday in the other session we created some damage, you see there is one incident of damage. But here, there is no such damage.

00:05:30 Let's have a look, if we open this. There's no damage found, everything is fine with this equipment.

00:05:40 And for the other equipment, there is a damage incident recorded – let's have a look.

00:05:47 This time, somebody has dropped this device. So whatever you want to do with this information, you want to consider that.

00:05:54 Okay, this is the first application. The second application that we will import – let's go to Web IDE – is a scanner for this,

00:06:05 so we spoke about a mobile application to help find out whether a certain item of equipment has been dropped. So let's go to "Workspace",

00:06:14 and import the file, "File", "Import", "From File System",

00:06:21 now we go to "equipmentscanner.zip", we open it,

00:06:27 and press "OK", and again we test this application, we run it...

00:06:38 So this is basically an application to just show information that we can bring to a mobile device. As we are now testing it locally, it looks different.

00:06:46 Also, we have no scanner, but we will fix that later. But if you go here, you can choose "Manual Mode",

00:06:53 and here it will give you some equipment numbers. You can do a manual check to see whether the service is basically working.

00:07:02 And here you have one damage incident found, it's the same device. And for the other you will have no damage.

00:07:10 Okay, so these are basically the applications. But let's look at what they do.

00:07:16 I mean, if we go again to "sensorworklist", we see the same logic again here.

00:07:23 In the "neo-app.json" file, we will see a link to this hub. So here, the hub destination is consumed.

00:07:33 And behind this path, from now on you can access the hub. Now we have exposed several services – let's have a look at these services.

00:07:43 To easily find them, we can use the search function, so we go here to this magnifying glass and, for instance, look for the service that we have found, and let's do this only in this single project,

00:07:58 so let's go to the "sensorworklist" project, and let's look for the equipment.

00:08:07 And there we can see the parts where the service is actually called. So let's go to the worklist.

00:08:16 In the worklist, there's a table – let's make this a bit smaller again – that wants to look for equipment. So the path is "Equipments".

00:08:29 This is pointing exactly to our OData service, and is getting some information here. And if we look in the later table, we see that there is a binding to what is in this.

00:08:45 So there are names for the device, ProductNames, ProductIds, EquipmentKeys. And this is exactly what we see in the application.

00:08:54 If we go to the worklist again, this is the data that's provided here. So again via the OData service, we were easily able to inject the data, independently of where it was coming from.

00:09:06 So the UI developer does not necessarily know that this is a Java application that mixed all this Now let's look for another one, so again we can also go for "Damage"

00:09:20 because the damage is also shown here. And you see here the same behavior.

00:09:26 So there's a path where the damage is actually referred to. So the service will be called to fetch the data, and it's not important where the data is coming from.

Page 21: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

21

00:09:39 What is also interesting – and we have used this – is "FreeDevice". "FreeDevice" was used in this precise operation to find out whether there is actually a sensor available that we could attach.

00:09:50 So here, again, you see... there is this registration...

00:09:57 in the registration dialog where we set the path to "FreeDevice". As in the previous units, I will not now go into the details of how to develop SAPUI5 – there is a wonderful openSAP course for this.

00:10:10 But I just want to point out that these are the integration points. Meaning that if you now know how the integration works

00:10:15 and you have this kind of path that simply points to some kind of an OData service, it's not so important to understand where it comes from,

00:10:23 but this we have shown, how to actually provide such an OData service. But now let's do something nice at the end.

00:10:31 So first of all, we need to deploy these to the launchpad to have it, so let's do this. I deploy it to the HANA Cloud Platform.

00:10:45 I register it to the launchpad. I call it "Register Sensor Devices".

00:11:04 I will not change the icon. And now it's an "Equipment Tracking" – we will now use the other group.

00:11:14 Put it there. And we finish that.

00:11:19 So if we now go to the launchpad, we have multiple applications – the "Manage Products" application and the "Product Analytics" application –

00:11:27 and register the sensors exactly like this, where we can now see which sensors we have generated. Now how do we get this to a mobile device?

00:11:36 The very simple way to do this and test this is as follows. We will now deploy the other application,

00:11:44 the "equipmentscanner". We will also deploy this to the HANA Cloud Platform.

00:11:52 And this will get a URL that you can call in any browser. But it will have a dependency to a plug-in that gives you access to the camera to scan.

00:12:00 So because of this, you need to run it in a special application container that you would usually create with a mobile build.

00:12:08 For now I will use the SAP hybrid application companion that will be available for various platforms and where you can test such applications.

00:12:16 So what I will do is open the active version of this application here, and now I have a link here. And with this QR code extension that we fetched earlier,

00:12:28 I have a QR code for this link. This is the first step.

00:12:31 The next thing is I will now go to my iPad device, and as you will see,

00:12:40 I have here an application "App Store", and in "App Store" I'm looking for "SAP Hybrid App Toolkit Companion". Yeah?

00:12:51 And I will download and install this. And this companion has a very nice feature.

00:12:59 It will allow me to simply scan this QR code and open the application on a mobile device. Okay.

00:13:11 It's close to being installed. I can now open it.

00:13:17 There it comes. I can protect it – I don't want to be protected.

00:13:23 I submit. And now I can do a double-tap

00:13:29 and enable a scanner here with this below. Yes, it is allowed.

00:13:36 And now I go to this QR code here. And I have the application running on my mobile device.

00:13:49 What does this mean? Let's go back a bit here.

00:13:55 I'll now go to "Sensor Worklist", where I have put for you a nice feature where if you hover and click on the name, you have a QR code.

Page 22: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

22

00:14:04 If I now click the scanning button, I can open the QR code,

00:14:14 and on my mobile device I will get the damage information. So the interesting part of this is that this kind of equipment code is usually attached to the device.

00:14:25 So with this mobile app, I can now go to any mobile device and read this QR code and find out whether it has been dropped in the past.

00:14:34 So now, for this for instance, if I scan it..., there is no such damage.

00:14:45 So if an employee now approaches IT support and says: "My device has a problem, it's defective", it can be very easily scanned and support can find out if the reason maybe is that it was dropped.

00:14:57 Okay, so this actually concludes Week 5 for the mobile and IoT extension. Now there's actually one thing left and, as you can see from this application,

00:15:13 this is that we have no clue whether it actually makes sense to attach this notebook to a sensor because from this sales order we don't know anything about your status.

00:15:24 So next week, we will try to find out whether we can link the status of the sales order and its role in the business process together with this extension.

00:15:33 Thank you.

Page 23: openSAP Extending SAP S/4HANA with SAP HANA Cloud …

© 2016 SAP SE or an SAP affiliate company. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other countries. Please see http://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices. Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors. National product specifications may vary. These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty. In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

www.sap.com