I was excited to hear the announcement about HANA Cloud Platform mobile services trial availability. This is a great opportunity to the developer community to try the/wp-content/uploads/2014/12/hcpms1_612219.png solution for free. HCPms is the cloud version of SAP Mobile Platform. SAP had another cloud version of SMP called SAP Mobile Platform, enterprise edition, cloud version it was deprecated.

Even there are few differences between SMP on-premise (SMP 3) and HCPms the mobile SDK is common for both, ie. an app written for SMP 3 runs against HCPms too without any code change – that caught my attention. Here I am going to run one of my existing hybrid mobile app developed for SMP 3 against HCPms.

Prerequisites

Activate HCPms

Apache Ant should be installed and added to path

Android SDK – It also requires Java

Node.js

Cordova – Version is 3.6.3-0.2.13

Git

SMP 3 SP05 SDK

Configure Application in HCPms

From the HCPms admin cockpit (https://hcpmsadmin-<your HANA account user name>.dispatcher.hanatrial.ondemand.com/sap/mobile/admin/ui/home/index.html) click on Applications> Click on Add icon on the bottom bar and provide below details:

Application ID : com.kapsel.logon

Name: com.kapsel.logon

Type: Hybrid

Security Configuration : Basic

Optionally provide Description and Vendor.

ScreenHunter_16 Dec. 19 11.24.jpg

Click on Save.

Next, click on Backend and provide the below details.

Backend URL : http://services.odata.org/V2/OData/OData.svc/

Authentication Type: No Authentication

ScreenHunter_18 Jan. 03 20.42.jpg

Save the configuration.

Develop Hybrid Mobile App

Follow this blog to develop a kapsel logon based hybrid app. Replace index.html with index.html. Only change needed to run the app with HCPms is providing the HCPms host and port.

Run cordova command:

cordova prepare

Connect phone with PC using USB and execute the cordova command:

cordova run android to run the app in the device.

Offline a Demo

Adding offline functionality to a hybrid app is quite easy using Kapsel plugins. Following the blog Getting Started with Kapsel Offline OData I have added the offline plugin to the app for a small demo.

  • Download datajs file and place it in www folder
  • Replace index.html with index.html
  • Execute below commands from the project path to add the offline plugin.

          cordova -d plugin add com.sap.mp.cordova.plugins.odata

          cordova plugin add org.apache.cordova.network-information

ScreenHunter_18 Jan. 03 19.43.jpg

Happy Coding !

Midhun VP

To report this post you need to login first.

34 Comments

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

  1. Gregor Wolf

    Dear Midhun VP,

    thank you for the walk through. I followed your steps and was able to register the app I’ve built using you sample. I thought I had to publish my app, but the publish failed with an error. So now let’s try the next step and call a OData service. Have you already tried to use the OData off-line functionality?

    Best regards

    Gregor

    (0) 
    1. Midhun VP Post author

      Hi Gregor,

      I just added the code for Odata offline. Hope that helps.

      Regards, Midhun

      SAP Customer Experience Group – CEG

      (0) 
    2. Martin Grasshoff

      HI Gregor,

      The “publish” button, exposes the App configuration to Mobile Secure (if you have connected your Mobile Secure Account to HCPms) and let you create Apps, which are able to retrieve the inial HCPms URL from mobile secure, resulting in an Application start where the user does not have to put it any configuration. He just logs on and uses the app.

      -Martin

      (0) 
        1. Martin Grasshoff

          Hi Gregor,

          yes, in the sense that the Discovery Service is working in the Trial – as I mentioned in my blog, there is almost no technical limitation.

          Anyhow, you need a separate Mobile Secure trial.

          Both systems needs to exchange some “secrets” in order to communicate. This is described in the documentation.

          -Martin

          (0) 
  2. Utsav Chobe

    Hello Midhun,

    Thank you very much for the update.

    • I have been working on SMP. I built a mobile App, using UI5, Cordova & offline (using kapsel secure storage + cordova network detection abilities) support with SMP3 SP3 – cloud version. In the experiment I used HCC to connect to on-premise backend.  As I understand, from your blog, I will not need to do any changes in my code to make it run with HCPms. Am I right? Or are there going to be considerations to be made, while moving to HCPms?
    • Further, what I am not very clear about (and so would like to request information  about) is the difference between “SMP3 – cloud version” and  “the new HCPms”.

              Quoting you – “HCPms is the cloud version of SAP Mobile Platform. SAP had another           cloud version of SMP called SAP Mobile Platform, enterprise edition, cloud version it           was deprecated.

              So what are the new capabilities (and/or deprecated capabilities like SMS services,           perhaps) that come with HCPms. Could you please guide me to some knowledge           source?

    Thanks in advance!

    Regards,

    Utsav Chobe

    (0) 
  3. Martin Grasshoff

    Hi Midhun VP,

    thanks for this content. Now I have to find a new topic for my upcoming document.

    This was exactly what I wanted to demonstrate next.

    Perfect!!

    Regards,

    Martin

    (0) 
  4. Patton Li

    Thanks for sharing, we are just moving to HCPms and learning the mechanism of HCPms.

    I’m looking forward to read more from you.

    Thanks and regards.

    Patton Li.

    (0) 
  5. Thanit Youruchatangern

    Hi Midhun,

    Thanks a lot for the blog. It’s very useful.

    I’ve followed you example for offline app connect to HCPms. It was working fine on the first run last week but when I tried it again today, it return an error

    An error occurred “[-10204] Communication with the server failed with status code: 500″”

    Do you have any clue if this is an issue on the server side or it’s something to fix on the js code?

    (0) 
    1. jitendra kansal

      Hi Thanit,

      As “HTTP 500” corresponds to “Internal server error”. There might be few reasons for this error.. e.g. something web wrong on server side but server cant give more specific info on what the exact problem is.

      I guess, you should create a new discussion at SMP Developer Center   > start a discussion

      and share the steps you followed with screenshots.

      Regards,

      JK

      (0) 
  6. Jared Commerford

    Hi Midhun,

    In your blog you said at this section:

    Develop Hybrid Mobile App

    Follow this blog to develop a kapsel logon based hybrid app. Replace index.html with index.html.

    The link for index.html isnt working for me. Would you mind sending me the contents of the file or checking the link?

    Thank you

    (0) 
    1. Midhun VP Post author

      Hi Jared,

      The link is working, I just checked.

      Since it’s not working for you I am pasting it here:

      <html>

          <head>

              <script type=”text/javascript” charset=”utf-8″ src=”cordova.js”></script>

              <script>

                  applicationContext = null;

                 

                  window.onerror = onError;

                  function onError(msg, url, line) {

                      var idx = url.lastIndexOf(“/”);

                      var file = “unknown”;

                      if (idx > -1) {

                          file = url.substring(idx + 1);

                      }

                      alert(“An error occurred in ” + file + ” (at line # ” + line + “): ” + msg);

                      return false; //suppressErrorAlert;

                  }

                  function logonSuccessCallback(result) {

                      alert(“Successfully Registered”);

                      applicationContext = result;

                  }

                 

                  function logonUnregisterSuccessCallback(result) {

                      alert(“Successfully Unregistered”);

                      applicationContext = null;

                      //sap.Logon.unlock(function () {},function (error) {});

                  }

                 

                  function register() {

                      if (applicationContext) {

                          alert(“Already Registered”);

                          return;

                      }

                      var appId = “com.kapsel.logon”; // Change this to app id on server

                     

                      // Optional initial connection context

                      var context = {

                          “serverHost”: “hcpms-P1000000trial.hanatrial.ondemand.com”, // HCPms host name

                          “https”: “true”,

                          “serverPort”: “443”,

                          “user”: “P1000000”,// HCPms admin user/ SCN User

                          “password”: “welcome123”, // HCPms admin password / SCN Password

                          “communicatorId”: “REST”,

                          “passcode”: “password”,

                          “unlockPasscode”: “password”,

                          “passcode_CONFIRM”:”password”

                      };

                      sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context);

                  }

                  function logonErrorCallback(error) {  

                      console.log(“An error occurred:  ” + JSON.stringify(error));

                      if (device.platform == “Android”) { 

                          navigator.app.exitApp();

                      }

                  }

              </script>

          </head>

          <body>

              <h1>HCPms Hybrid App</h1>

              <button id=”register” onclick=”register()”>Register</button>

          </body>

      </html>

      Regards, Midhun

      SAP Technology RIG

      (0) 
  7. Iris ST

    Hi Midhun VP,


    Thanks for your sharing. I have created LogonDemo and used iOS simulator to register successfully.

    My question is how to configure my LogonDemo application in HCPms to use my on-premise LDAP Server as a cloud user store or or how to configure it by using kapsel deploy command. 

    I have already had cloud connector and configured it to use our LDAP AD. And, the destination/backend connection of onpremiseumconnector has been defined also.

    The reference is Configuring User Store in the Cloud Connector.(SAP HANA Cloud Platform). It gave an neo command for JAVA applications.

    Thanks for your help.

    Best Regards,

    Iris

    (0) 
  8. Georgie Nushev

    Hi Midhun,

    Thanks for the post!

    By pressing the button “Register” i got the error:

    sap is not defined, where calling the method sap.Logon.init .

    Any idea what my mistake is?

    Regards,

    Georgi

    (0) 
    1. Midhun VP Post author

      Hi Georgi,

      Could you double check whether you added the Logon plugin using the command cordova -d plugin add com.sap.mp.cordova.plugins.odata

      Regards, Midhun

      SAP Technology RIG

      (0) 
      1. Georgie Nushev

        Hi Midhun,

        I’ve added the Logon plugin by typing: cordova -d plugin add C:\SAP\MobileSDK\KapselSDK\plugins\logon ,

        typing the cordova -d plugin add com.sap.mp.cordova.plugins.odata in the cmd got an Error: 404 Not found : com.sap.mp.cordova.plugins.odata

        Just checked by typing cordova plugins and got response :

        com.sap.mp.cordova.plugins.logon 3.5.0 “Logon”

        Regards,

        Georgi

        (0) 
        1. Midhun VP Post author

          Hi Georgie,

          You should be able to add the required kapsel plugins. Please follow this blog: Getting Started with Kapsel – Part 2 — Logon and use replace the index.html wiith the one I given. Sorry the logon plugin command is cordova -d plugin add com.sap.mp.cordova.plugins.logon

          You are getting the above mentioned error because the required plugins are missing in your project.

          Regards, Midhun

          SAP Technology RIG

          (0) 
          1. Georgie Nushev

            I’ve just added the odata plugin and its dependencies – corelibs and AuthProxy.

            But now I’m getting the error “cannot call method ‘init’ of undefined” of the same code line

            (0) 
                1. Georgie Nushev

                  Hi Midhun,

                  – codova -d create D:\Path com.kapsel.logon KapselLogon

                  – cordova platform add android

                  – cordova -d plugin add D:\Path-to-logon-plugin”

                  -cordova -d prepare

                  – added the other plugins and its dependencies (odata, corelibs, authproxy)

                  My app in the HCPms:

                  KapselLogon.PNG

                  (0) 
                  1. Midhun VP Post author

                    Hi Georgie,

                    When you are creating project you have to mention the SMP SDK kapsel plugins path too.

                    Ex.

                    cordova -d create C:\Kapsel_Projects\LogonDemo com.mycompany.logon LogonDemo “{\”plugin_search_path\”:\”C:/SAP/MobileSDK3/KapselSDK/plugins/\”}”

                    Regards, Midhun

                    SAP Technology RIG

                    (0) 
  9. Dhani Sebastian

    Hi Midhun,

    I have enabled my HCP Mobile server and configured an application in the Cockpit.


    I want to authenticate my username and password against the gateway username and password while onboarding.

    According to this document, https://help.hana.ondemand.com/hana_cloud_platform_mobile_services/SAP_HANA_Cloud_Platform_Mobile_Services.pdf, I found that I have to enable SCIM service if I want to authenticate with the backend while onboarding.

    Is it possible to enable SCIM service for trial account?

    If possible, then how to do that?

    Do I have follow some steps(like creating destination in Cloud Platform Cockpit) after enabling SCIM service?


    Thanks,


    Dhani

    (0) 
      1. Dhani Sebastian

        Hi Gregor,

        Thanks for your reply.

        I will try with your project for authentication.

        I have already used the SAP Cloud Connector to connect to my on-premise backend.

        So do you mean to say that right now we cannot enable SCIM service for trial account?

        Thanks,

        Dhani.

        (0) 
        1. Iris ST

          I have the same question.

          I have an application in HCPms and SAP Cloud Connector already to

          a. exposing backend services, and

          b. having corporate LDAP as an user store

          For user authentication, should I enable SCIM service? And, how it could be implemented at mobile app side, via Client Hub and Kapsel Logon Plugin?

          (0) 
        2. Gregor Wolf

          Hi Dhani,

          as you can use the Cloud Connector also for the Trial Landscape it’s absolutely possible to use an SICF (That is the correct name of the transaction) Service.

          Best regards

          Gregor

          (0) 
  10. Jens Glander

    Hi Midhun VP,

    Thank for your helpful description how to use HCPms together with mobile Kapsel applications.

    Together with two SCN blogs from Daniel Van Leeuwen (http://scn.sap.com/docs/DOC-49524 and http://scn.sap.com/docs/DOC-62109) and your blog I managed finally to run the Logon Kapsel application on my android device and I registered a user on my Trial HCPms account by means of this app (using BASIC and NONE security types, both worked).

    But for my HCPms on landscape hana.ondemand.com the user registration does not work with the same Kapsel Logon application when using BASIC security type configuration for the Kapsel Logon app in HCPms UI.

    The NONE security type configuration worked also on hana.ondemand.com, i.e. in that case users could be registered.

    But I want to registered secured users which are connected to the account and the HCPms service by a SAML-configuration of an SAP Cloud IdP (SCI) which is connected already to my account.

    Do you have an idea what might be the reason why the BASIC secu type (I also tried FORM, i.e. SAML but failed as well) does not work in the described situation?

    Thank you very much for any help on this issue.

    Best regards,

    Jens

    (0) 
    1. Jens Glander

      Hi,

      I’ve just figured out that my Kapsel Logon App I mentioned in my last comment also works on my hana.ondemand.com HCPms account with security type BASIC.

      What was my mistake?

      My HCPms account on hana.ondemand.com is connected to SAP Cloud IdP (SCI), so I thought that the users which could register via the Logon Kapsel App are the users defined in the SCI.

      But this seems not to be the case by default: Still the SAP IdP (i.e. SCN users) is the relevant users store for registering authenticated users.

      I will ask a new question in the forum (see here) how to change my HCPms so that my SCI (and not SAP IdP) is taken as basis for users to be registered.

      Best regards,

      Jens

      (0) 

Leave a Reply