SAP’s mobile solution is now available on the HANA Cloud Platform. It is called HANA Cloud Platform mobile services (HCPms), it enables mobile application development, configuration and management. HCPms is a real MaaS offering so SAP takes care of upgrades, backups, patching, scalability etc,. To the developer community the happy news is that HCPms is available as a trial through hanatrial.ondemand.com.
There are few difference between SMP on-premise (SMP 3) and HCPms, but the SDK is common for both. Hence the app developed for SMP 3 runs on HCPms too without any code change. If you are developing any enterprise mobile application, you can make it work offline (CRUD) using HCPms. Here I am explaining how to develop an offline mobile app that runs on HCPms. For this you need to activate HCPms trial, Apache ANT, Node.js, Cordova version 3.6.3-0.2.13 and SMP SDK SP05.
Add Application in HCPms
- Login to HCPms (https://hcpmsadmin-<your HANA account user name>.dispatcher.hanatrial.ondemand.com/sap/mobile/admin/ui/home/index.html).
- Click on Applications, then click on Add icon on bottom left and provide below details:
Application ID : com.kapsel.logon
Name: com.kapsel.logon
Type: Hybrid
Security Configuration : Basic
Optionally provide Description and Vendor.
- Click Save
- Next, click on Backend and provide below details:
Backend URL : http://services.odata.org/V2/OData/OData.svc/
Authentication Type: No Authentication
- Save the configuration
Create Offline Hybrid Mobile App
One type of mobile app that can be developed using HCPms is an HTML5 hybrid app based on Apache Cordova. Kapsel is a set of Cordova plugins that comes with SMP SDK. Logon and Odata Offline Kapsel plugins in a Cordova project enables registration of mobile app with HCPms and offline feature. Execute below cordova commands to create an offline app.
- Create Cordova project using the command:
cordova -d create C:\Kapsel_Projects\OfflineDemo com.mycompany.offline OfflineDemo “{\”plugin_search_path\”:\”C:/SAP/MobileSDK3/KapselSDK/plugins/\”}”
cd C:\Kapsel_Projects\OfflineDemo - Command to add Android platform support to the project:
cordova -d platform add android - Add Logon, Offline and Network info plugin using the command:
cordova -d plugin add com.sap.mp.cordova.plugins.odata
cordova -d plugin add com.sap.mp.cordova.plugins.logon
cordova plugin add org.apache.cordova.network-information - Download datajs file and place it in www folder
- Replace index.html with index.html
- Execute below command to copy the files to the Android platform folder
cordova -d prepare - Run the project using the command (you have to either connect your phone with PC or setup an Android simulator to execute this command)
cordova run android
How it works ?
An offline store (local DB in device called ultraliteDB) will be created when the device is online, that stores the specified Odata collection, later when the device is offline a custom HTTPClient will be applied (sap.OData.applyHttpClient();) over the actual HTTP call hence the data will be pulled from local DB instead of making an actual HTTP request.
Defining an Odata collection to use it offline:
“definingRequests” : {
“ProductsDR” : “/Products“
}
Odata collections in the service:
When the device comes online, local changes made to the offline store can be send to backend via a call to sap.flush(); and the offline store can be updated by calling store.refresh();
References: http://scn.sap.com/docs/DOC-58063
Nice Article
Could you fix the “index.html” link? Thanks