Skip to Content

Ok, Craig has already blogged about the funny AWS IoT Button and how we can integrate this in our SAP (hxe) world.

But anyway for me as an SAP CP Integration fan and a guy who loves SAP innovation and technical things like SAP CP IoT, it was clear that we need a blog on how we can do this with SAP CP integration as well ;o)

Let´s go…..

AWS Lambda

The Lambda function is a pretty simple.

As a newbie on AWS, I´ve started here with the simple email template:

After I’ve understood how this works, I just switched to the example from Craig´s blog with some changes.

I know we can also check the “Click Type” in the Lambda function and can then execute different actions, but why not using SAPCP integration.

The final Lambda function looks now like this:

'use strict';

const AWS = require('aws-sdk');
var https = require('https');

exports.handler = (event, context, callback) => {
    console.log('Received event:', event.clickType);
    var poxy_host_sapcpi = "myproxyapp*.hana.ondemand.com";
    var proxy_path = "/SAPCPI"; 
    var body = JSON.stringify({"SN":`${event.serialNumber}`,"BATTERY": `${event.batteryVoltage}`,"TYPE":`${event.clickType}`});
      
var request = new https.request({
        hostname: poxy_host_sapcpi,
        port: 443,
        path: proxy_path,
        method: "POST",
        headers: {
            'Content-Type': 'application/json; charset=utf-8',
            'Accept': '*/*'
        }
    });
    request.end( body );
    request.on('response', function (response) {
    console.log('STATUS: ' + response.statusCode);
    if( response.statusCode === 201 ){
        console.log("Successfully received response system");
        callback("Processed correctly");
    }
});
};

UI5 proxy app

As you can see, I used a “proxy app” for the first try and not the SAP CPI iflmap URL.

For this aproach I used the destination which I´ve defined in the SAP CP cockpit, which points to my iflmap url:

 

On the other side I used this destination in my neo-app.json

 {
      "path": "/SAPCPI",
      "target": {
        "type": "destination",
        "name": "SAPCP_Integration",
        "entryPath": "/http/aws_iot"
      },
      "description": "SAP Cloud Platform Integration"
    }

The path is now identical to the path used in the Lambda function and the entryPath fits to my http sender endpoint of my upcoming iflow.

And additional switching (thx Gregor for the hint at SAP Inside Track Hannover ;o) ) of the authentification, pls check here for details:

 "authenticationMethod": "none",

Now its possible to enter the “iflmap” w/o authentification.

if you enter the “proxy” url plus the path you get now the following “good” error directly from SAP CP integration. This indicates we can now access SAP CP integration via the proxy app without authentification.

Time for the integration stuff….

The final simple iflow has the folowing structure.

As you can see there is now magic and therefore I think it’s not requiered to go deeper in the details.

My target action/sytem will be a mail for a “double” click and for a “long” or “single” click I will store the button informations in an HANA table:

After I execute an specific click….

e.g a “single” or “long” click I can now see my AWS iot button data on my HANA table:

And by a “double” click I got a mail:

 

cheers,

fabian

 

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply