The last weeks i´ve startet this little sceanrio:
|
|
|
|
|
- Consume SAP CP IoT service Data via SAP CP Integration and start an simple approval Workflow (this blog)
|
...to show you how we can get data from SAP CP IoT service check this via SAP CP Integration against SAP CP Business Rules:
Now it´s time to show u how we can start our next step to create an simple approval wf and a custom SAP UI5 app to show some details about our IoT alert.
Always here our story starts with two simple SAP CP integration iflows, as i shown last week our last step was to comapre our IoT measure again the well defined rule. As result we got the "Alertlevel":
Now we post this "Alertlevel" to our next SAP CP Integration flow:
The endpoint here is something like "wfs_start":
Which is exactly the definition how we can start the next iflow:
As already documented
here or in the API hub
here we need first our XSRF token from the workflow servces and finally we start the instance.
I want not to go more deeper here, because i´ve already explained this in this
blog.
The Workflow
Since my last SAP CP Workflow services blog we have now the move of our design time in the WebIDE Full-Stack great thing from my perspective to orchestrate more an more tools in a central one good job guys stephan.schluchter christian.loos and many more
Our final workflow looks now like this:
Some detail about or tasks:
Task |
Summary |
 |
In this task we call SAP CP IoT service to get more informations about our sensor. |
 |
The Approval step here the business user can decide if the alert is a real problem and if this is the case he can create an ticket in c4s. |
 |
The litte script task is used to prepare a context for my call to SAP HANA |
 |
In this step i want to write some data in a litte HANA table to track my alers |
 |
Here we create our ticket in SAP hybris C4S |
I think one of the best ways to check what´s happen during the wf is running is a look in the context of the wf instance. Please read
here for more details.
So if we now hav start our workflow instance we can now see the folowing context:
{
"alertLevel": "FATAL",
"capabilityId": "b0e65a4b-0b4b-4707-8bd3-0e375a0390be",
"sensorId": "25",
"timestamp": 1506504860169,
"measure": {
"Temperature": "26.7"
}
}
Based on the information that we get here the "sensorId" we call now SAP CP IoT service again to retrieve additional data. The context looks after the call like this:
{
"measure": {
"Temperature": "26.7"
},
"capabilityId": "b0e65a4b-0b4b-4707-8bd3-0e375a0390be",
"alertLevel": "FATAL",
"SensorDetail": {
"id": "25",
"deviceId": "11",
"sensorTypeId": "11",
"name": "Sycor_Sensor_0815",
"alternateId": "445907d2c683c00f"
},
"timestamp": 1506504860169,
"sensorId": "25"
}
If we now go to our Fiori Launchpad on opening our "Task" we see now these information in a simple UI5 app:
In the app i call here once more the SAP CP IoT service API to retrieve the last 5 measuremnts:
If we go now ahead wit our process an we decide us "yeah that´s an real alert we need an technican" we press simple "Create Ticket" an enter an message for the technican:
If we now submit and check again our context we see some more data:
{
"iotApproved": "true",
"measure": {
"Temperature": "26.7"
},
"hanaxs": {
"ID": "1",
"SENSORID": "25",
"ERRONEOUS_VALUE": "26.7",
"ACK": "true",
"TICKET": "true",
"ERRORTYPE": "FATAL",
"TICKET_ID": ""
},
"capabilityId": "b0e65a4b-0b4b-4707-8bd3-0e375a0390be",
"alertLevel": "FATAL",
"SensorDetail": {
"id": "25",
"deviceId": "11",
"sensorTypeId": "11",
"name": "Sycor_Sensor_0815",
"alternateId": "445907d2c683c00f"
},
"iot": {
"message": "Dear technican, please check sensor 25 we detected here an alert with an exceeded measurement. thx and br, fabian",
"alertlevel": "FATAL",
"capabilityId": "b0e65a4b-0b4b-4707-8bd3-0e375a0390be",
"Sensorname": "Sycor_Sensor_0815",
"deviceId": "11",
"sensorTypeId": "11",
"alternateId": "445907d2c683c00f",
"Temperature": "26.7",
"timestamp": "1506504860169"
},
"timestamp": 1506504860169,
"sensorId": "25"
}
As we can see we´ve now to more new context nodes "iot" and "hanaxs" i´am using this to post the "hanaxs" content to my little HANA table:
An the "iot" content is used to create my ticket:
For my ticket also SAP CP Integration plays the "center" to map my data to the required C4S structure.
Finally we see now the ticket and.....damn it works:
On the HANA side
As already mentioned i store my ticket also in HANA, in one of the next blogs we can talk about SAP Analytics Cloud. I think i will analyze my data there to get some infos what happen with my sensors.
But anyway HANA now, ok i created here..."no magic" only a simple table:
@Catalog.tableType : #COLUMN
Entity alerts {
key ID: Integer;
TIMESTAMP: SDate;
SENSORID: Integer;
ERRONEOUS_VALUE: Double;
ACK: String(100);
TICKET: String(100);
ERRORTYPE: String(100);
TICKET_ID: String(100);
};
To access the data i defined here an xsodata service:
service namespace "development.iot_alerts"
{
"FABIAN"."development.iot_alerts::iot_alerts.alerts"
as "ALERTS" create using "development.iot_alerts::iot_alerts_proc";
}
The final structure of my xs application looks like this
And yes alwas for this i build up an little UI5 app.
We can found this now on our "FLP" :
That´s it......
Ok u see the ticket id is currently missing, right i´am working still on this that we get the C4S reference.
In the next blog i think we can have a look how we can us e.g. SAP Analytics Cloud for my little scenario.
cheers,
fabian
p.s. asap i will provide my ui5 app source on git