Skip to Content

Awhile ago I published a blog about using the SAP HANA Cloud Platform, in particular the SAP HANA instance within the platform to connect my Amazon Echo and OData sources together.

After publishing and fielding questions around what I did I started to think, could I do more? Could I use ABAP? The answer I am happy to report is YES, yes you can use ABAP.

So I began the journey by dusting off my books on ABAP, the last time I actually did ABAP to any extent I think was over 10 years ago so I was rusty to say the least. Considering my dated skills I wanted to start small so I stuck to a simple “unlock my user” scenario. Basically when I forget my password since I have not logged in for 10 years I’ll be able to ask Alexa to unlock my user for me when I enter the wrong password too many times.

I began with my ABAP system, which I was able to get up and running in a matter of minutes via the SAP Cloud Appliance Library. Then got my developer key in there and started coding away in SE80!

 

I was on top of the world, I had an ABAP Function created, then an ABAP Class, then started pounding away in SICF and SMICM and RZ10… life could not have been better! I had my services enabled, and I was hitting my newly created stuff!

Wham! URL called!

And the results were in!

Talk about BRILLIANT! I was on fire, 10 years and I still had it! Truly I was on top of the world! Until of course I meet with Lucia Subatin (who fixed many of my coding errors) and Gregor Wolf who showed me the light! Apparently a lot, and I do mean a lot has changed in the past 10 years!

Thanks to Lucia showing me and reminding me about the ins and outs of ABAP coding and then Gregor taking the time to sit down with me and walk me through the transaction SEGW (we really should call it the Gregor Wolf transaction now! haha) as well as walking me through how to get that services setup the final result would not have been possible.

Through the SAP Gateway Service Builder I was able create a new project.

Add a new Function Import

Set the parameters

And of course needing to jump over to create a service

Then of course my coding and redefinition in the EXT class

Then finally the testing, and life was good again. There are actually quite a few more steps in there and you can find more coming soon to the tutorials of the SAP Developers Center.

The real key here though was to make this work with the Amazon Echo I needed to consider security and issues around HTTPS. So the Cloud Connector was added next, fantastic context sensitive documentation means totally easy to add yourself!

From there I needed to create a destination in the SAP HANA Cloud Platform and then connect that to a new app in through Web IDE which gave me the ability to easily call my service and any new services later. So the extra effort one time definitely pays out in the end.

Again a simple blog does not do justice to what Gregor showed me in an intense (in the hotel bar) crash course so watch for the tutorials coming soon!

Now with the ABAP coding done, the Cloud Connector installed and my ABAP server connected to my Trial Account it was time to turn my attention to my Node JS code on the Echo. I just modified the code I used already.

First a new variable to distinguish my access to ABAP over HCP.

var host_abap = 'abapproxy-d045495trial.dispatcher.hanatrial.ondemand.com';

Then a new function was added.

var getResponseFromABAP = function(itemName, callback){
    var lv_url = url(itemName);
    console.log(lv_url);
    console.log(host_abap);
    var options = {
            method : 'GET',
            host : host_abap,
            path : lv_url,
            headers:{
                        'Content-Type': 'application/json;charset=utf-8',
                        'Accept': 'application/json'
                    }
        };
    https.get(options, function(res){
        var body = '';
    
        res.on('data', function(data){
            body += data;
        });
    
        res.on('end', function(){  
            var result = JSON.parse(body);
            callback(result.d.Message);                
        });
    
    }).on('error', function(e){
            console.log('Error: ' + e);
    });
}; 

Now it was just a matter of determining which to call based on my Alexa Skill intent handler. Hard to show the end result since I am still on the road in a hotel so I grabbed a quick screen shot from the built in test environment for the Alexa Skills.

You can see in the “outputSpeech” that the text indicates my “User D045495 unlocked, if this is permitted in this system”  which matched perfectly to what my ABAP code returned.

Needless to say, my original approach was completely outdated so I was very lucky to have 2 people close by to help me move forward and even though there were several initial steps needed I’m amazed how easy the next service will be! I’m already planning out the tutorial sets to recreate what I did on the ABAP side!

To report this post you need to login first.

3 Comments

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

  1. Roberto Calcopietro

    Hi Craig, excellent work! It is nice to know that you still have the touch 🙂

    Sends my regards to Lucia (an old friend).

    I’m working in an Fiori App very similar for my company, so it is really encouraging knowing that this can be done.

    Kind regards,

    Roberto.-

    (1) 

Leave a Reply