Vous êtes sur la page 1sur 41

SAP Mobile - Webinar Series

SAP Mobile Platform 3.0


Developing Offline Apps with the
Kapsel SDK




Jeff Gebo
Customer Experience Group
SAP

2013 SAP AG or an SAP affiliate company. All rights reserved.

Brought to you by the Customer Experience Group

SAP Mobile Platform 3.0


Enablement

We bring to you all you need to


successfully install and run the "
SAP Mobile Platform 3.0.

On SCN Pages, you find links to
White Papers, How-To Guides,
Blogs and other resources:
http://scn.sap.com/docs/
DOC-49476

Webinars complement these
published resources:"
http://scn.sap.com/docs/
DOC-55282

2013 SAP AG or an SAP affiliate company. All rights reserved.

Legal Disclaimer

The information in this presentation is confidential and proprietary to SAP and may not be disclosed without
the permission of SAP. This presentation is not subject to your license agreement or any other service or
subscription agreement with SAP. SAP has no obligation to pursue any course of business outlined in this
document or any related presentation, or to develop or release any functionality mentioned therein. This
document, or any related presentation and SAP's strategy and possible future developments, products and
or platforms directions and functionality are all subject to change and may be changed by SAP at any time
for any reason without notice. The information in this document is not a commitment, promise or legal
obligation to deliver any material, code or functionality. This document is provided without a warranty of any
kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness
for a particular purpose, or non-infringement. This document is for informational purposes and may not be
incorporated into a contract. SAP assumes no responsibility for errors or omissions in this document, except
if such damages were caused by SAPs willful misconduct or gross negligence.

All forward-looking statements are subject to various risks and uncertainties that could cause actual results
to differ materially from expectations. Readers are cautioned not to place undue reliance on these forwardlooking statements, which speak only as of their dates, and they should not be relied upon in making
purchasing decisions.

2013 SAP AG or an SAP affiliate company. All rights reserved.

Agenda

Kapsel Overview
Offline OData Service
Kapsel OData Plugin
Demo

2013 SAP AG or an SAP affiliate company. All rights reserved.

Kapsel Overview

Container-Based Applications on Mobile Devices - Apache


Cordova
Mobile Device

When a browser-based application is executed on a mobile device, the JavaScript coding normally
has no access to hardware features of the mobile device such as the accelerometer, GPS location or
the camera etc.
In order for a web-based application to gain access to these hardware features, it is necessary to run
the application within a container that acts both as a browser and provides an API to access the
hardware.
Apache Cordova (formerly known as PhoneGap) provides this container.
2013 SAP AG or an SAP affiliate company. All rights reserved.

Apache Cordova

PhoneGap is an open source hybrid application framework originally created by


Nitobi
PhoneGap donated to Apache Foundation as Apache Cordova
Nitobi Acquired by Adobe Adobe/Nitobi team now focused full time on the
project
Fastest moving open source project on the planet; releasing minor versions
monthly and major versions yearly
Contributors include IBM, Microsoft, Intel, Mozilla, BlackBerry, and more
Apache Cordova and Adobe PhoneGap are essentially the same thing; PhoneGap
is Adobes distribution of Cordova with some extra stuff tacked on

2013 SAP AG or an SAP affiliate company. All rights reserved.

Cordova High Level Architecture


Mobile Device
Native Application
Web View
JavaScript, CSS, HTML, etc.

Plugin
JavaScript API

Plugin
JavaScript API

Plugin
JavaScript API

Plugin
JavaScript API

Native API

Native API

Native API

Native API

2013 SAP AG or an SAP affiliate company. All rights reserved.

Cordovas standard PlugIns


Events
pause, resume, online, offline, backbutton, menubutton,
Notification
alert, confirm, prompt, beep, vibrate
Capture
(Capture media files using device's media capture applications)
Storage (DB device storage interface)
Geolocation
File
Media (audio recording an playback)
Contacts

2013 SAP AG or an SAP affiliate company. All rights reserved.

Cordovas User Interface

2013 SAP AG or an SAP affiliate company. All rights reserved.

10

Why do we use Cordova instead of doing it from scratch?

Developer community that needs little ramp-up

Better performance at app startup and page loading

Network whitelisting approach to handle most web security threats


(see html5sec.org)

Config.xml approach to configure web app and turn on/off plugins

Dont need six months to support a platform that PhoneGap already supports

No native screens needed for list of workflow screen pincode / etc. use InAppBrowser
approach

Web developers do not need to understand native code for customizing container

2013 SAP AG or an SAP affiliate company. All rights reserved.

11

Apache Cordova 3

Beginning with Apache Cordova 3.0, the


Cordova container is simply a container
Any APIs and extensions to the container
implemented as plugins
Added command line interface (CLI) for
managing Cordova applications and
application development process

2013 SAP AG or an SAP affiliate company. All rights reserved.

12

Kapsel - SAP Specific Plug-Ins for Cordova


SMP3 Server

Mobile Device

HTTP(S)

In order for a Cordova-based web application to be able to interact with SMP3, SAP has provided a
set of plugins that are collectively known as Kapsel. These plugins are part of the larger SMP
Mobile SDK.
In this presentation, we will be focusing on the use of the Kapsel Logon and OData plugins.

2013 SAP AG or an SAP affiliate company. All rights reserved.

13

Kapsel SDK
Part of the SAP Mobile Client SDK.
Contains Plugins
Contains Fiori Client
Command Line Interface (CLI)

2013 SAP AG or an SAP affiliate company. All rights reserved.

14

Kapsel

3rd party plugin

Kapsel is a set of SAP specific plugins


for Apache Cordova

3rd party plugin


AppUpdate

Provides enterprise capabilities to a


Cordova application

Supports Android (4.0+) and iOS (6.0+)


today; Some support for Windows
Phone 8.1
A single web application can be
provisioned into the container

EncryptedStorage
Logger

Cordova

Logon
Push
OData

Kapsel Plugins

Fits cleanly within existing Cordova


development environments and
processes

AuthProxy

E2E
Barcode Scanner
Online App
App Prefs

2013 SAP AG or an SAP affiliate company. All rights reserved.

15

Kapsel Plugins

1.

AppUpdate

5.

OData

2.

AuthProxy

6.

Push

3.

EncryptedStorage

7.

E2E

4.

Logon

8.

Barcode Scanner

5.

Logger

9.

Online App

6.

Push

10.

2013 SAP AG or an SAP affiliate company. All rights reserved.

App Preferences
16

Kapsel - Microsoft Windows Support

Available Kapsel plugins on Windows


8.1:

AuthProxy
Encrypted Storage
Logger
Logon
Push
Settings

Available Kapsel plugins on Windows


Phone 8.1:

AuthProxy
Logger
Logon
Push
Settings

Support of OData plugin for offline


will come in a later release

2013 SAP AG or an SAP affiliate company. All rights reserved.

17

Offline OData

Traditional Mobile Offline


Mobile App
Mobile Model

Mobile Platform SDK

Mobile Middleware
Mobile Model

Backend

Mobile MW Services

2013 SAP AG or an SAP affiliate company. All rights reserved.

19

OData as the Common Model


CSDL = OData Entity Model
Online with Caching

Offline

Offline with Staging

Mobile App

Mobile App

Mobile App

CSDL

OData SDK

CSDL

OData SDK

CSDL

OData SDK

Mobile Services
Mobile Services

Mobile Services
Data Staging Area

Backend

Backend

CSDL

Backend
CSDL

2013 SAP AG or an SAP affiliate company. All rights reserved.

CSDL

20

Offline OData and SMP 3.0 SP4


Mobile Client
Native App

Kapsel

Mobile Platform SDK


Mobilink
Protocol over
HTTP

UltraLight

Offline Store

Online Store

SAP Mobile Platform


OData Offline Service
Client Store Provisioning and Refresh
Delta Enablement
OData Cache

Backend OData Producer

2013 SAP AG or an SAP affiliate company. All rights reserved.

21

Initial Download Sequence


Optimized Offline
OData Transport

Mobile App

OData
Producer

Request Initial Download


(seed URLs)

Request Metadata
return
Initialize
Database
For each Seed URL

Request Data

Data
Populate
Database

If not Delta Enabled

Cache Keys

Database Filename
Request Database

File download

2013 SAP AG or an SAP affiliate company. All rights reserved.

22

Request for Refresh Sequence


Optimized Offline
OData Transport

Mobile App

OData
Producer

Request for Refresh


(seed URLs)

For each Seed URL

If Delta Enabled
Request Data with delta token
Data

If not Delta Enabled


Request Data
Data
Retrieve Keys
from Cache
Compute Delta

Transform all changes to


relational / Mobilink protocol
Data
Apply changes to Database

2013 SAP AG or an SAP affiliate company. All rights reserved.

23

Local Updates Sequence


Optimized Offline
OData Transport

Mobile App
Offline

OData
Producer

Create, Update or Delete Data

Update DB to reflect pending


change
Request (POST, PUT, PATCH,
BATCH) added to Request Queue

Queries on data reflect pending updates

Online

Process Request Queue


For each Request

Request
Response

Etags are checked for potential


conflicts

Errors & Successes (Etags, Location Headers)


All errors along with their original
requests are stored in the Error Archive

Request for Refresh


See Request for
Refresh Sequence

Delete local change from DB

2013 SAP AG or an SAP affiliate company. All rights reserved.

24

A SAPUI5, Cordova-Based Application Running in Online


Mode
Mobile Device

SMP3 Server

OData Server
SAP Gateway or HANA

HTTP(S)

Since the mobile device has network


connectivity, the container-based app can
perform direct OData operations against the
backend server using SMP3 as a proxy
server.

2013 SAP AG or an SAP affiliate company. All rights reserved.

HTTP(S)

The client app receives a realtime response from the backend


server

25

A SAPUI5, Cordova-Based Application Running in Offline


Mode 1/5
Mobile Device

SMP3 Server

OData Server
SAP Gateway or HANA

HTTP(S)

HTTP(S)

1. In order to use an app in offline mode, you must first have


network connectivity to the SMP3 server.

2013 SAP AG or an SAP affiliate company. All rights reserved.

26

A SAPUI5, Cordova-Based Application Running in Offline


Mode 2/5
Mobile Device

SMP3 Server

OData Server
SAP Gateway or HANA

HTTP(S)

HTTP(S)

1. In order to use an app in offline mode, you must first have


network connectivity to the SMP3 server.

Offline
Store

2. The Kapsel OData plugin extracts information from the backend


server and stores it in an offline store held locally on the device.

2013 SAP AG or an SAP affiliate company. All rights reserved.

27

A SAPUI5, Cordova-Based Application Running in Offline


Mode 3/5
Mobile Device

SMP3 Server

OData Server
SAP Gateway or HANA

1. In order to use an app in offline mode, you must first have


network connectivity to the SMP3 server.

Offline
Store

2. The Kapsel OData plugin extracts information from the backend


server and stores it in an offline store held locally on the device.
3. The app can now operate without the need for any network
connectivity by performing operations on the data held locally in
the offline store.

2013 SAP AG or an SAP affiliate company. All rights reserved.

28

A SAPUI5, Cordova-Based Application Running in Offline


Mode 4/5
Mobile Device

SMP3 Server

OData Server
SAP Gateway or HANA

HTTP(S)

HTTP(S)

4. When network connectivity is re-established, the offline store


must be synchronized with the backend server. This is a 2-step
process:

Offline
Store

2013 SAP AG or an SAP affiliate company. All rights reserved.

a) Local modifications made to the offline store must be flushed to the


backend. Think of this as pushing out the changes I have made.

29

A SAPUI5, Cordova-Based Application Running in Offline


Mode 5/5
Mobile Device

SMP3 Server

OData Server
SAP Gateway or HANA

HTTP(S)

HTTP(S)

4. When network connectivity is re-established, the offline store


must be synchronized with the backend server. This is a 2-step
process:

Offline
Store

2013 SAP AG or an SAP affiliate company. All rights reserved.

a) Local modifications made to the offline store must be flushed to the


backend. Think of this as pushing out the changes I have made.
b) The offline store must also be refreshed with any changes made by
other users of the same application.
Think of this as a pulling in the changes other users have made.

30

Miscellaneous Topics

Specifying indexes to the client DB


OData Caching (Feeds with no user context)

Known Offline OData Constraints

o No support for function imports


o No support for $value / binary data

2013 SAP AG or an SAP affiliate company. All rights reserved.

31

OData Plugin

OData Plugin
Accessing OData Offline createOfflineStore()

Call method createOfflineStore() to create an OfflineStore object.


<static> createOfflineStore(properties) -> sap.OfflineStore
Properties an object with property values for creating the Offline Store. Example:

var properties = { "name": "travel, "host": connectionInfo.serverHost,



"port": connectionInfo.serverPort,



"https": connectionInfo.https,

"serviceRoot" : connectionInfo.serviceUrl,

"definingRequests" : { "req1" : "/TravelAgencies_DQ },

"customHeaders" : connectionInfo.headers }

var store = sap.OData.createOfflineStore(properties);

2013 SAP AG or an SAP affiliate company. All rights reserved.

33

OData Plugin
Accessing OData Offline OfflineStore Method open()

Call the open() method to open the offline store. Must be online at the stage!
Creates local database on the device.
open(success_callback, error_callback)
success_callback function called if store was opened successfully.
error_callback function called if error was encountered when opening store.
Example:
store.open(store_open_success, store_open_failure);

2013 SAP AG or an SAP affiliate company. All rights reserved.

34

OData Plugin
Accessing OData Offline applyHttpClient()

Call applyHttpClient() applies custom OData.defaultHttpClient with custom Http


Client that will access local database for requests that are mapped to the Offline
Store.
<static> applyHttpClient()
Example:
sap.OData.applyHttpClient();
Call when you want to go offline!
Can remove with the removeHttpClient() call:
sap.Odata.removeHttpClient();

2013 SAP AG or an SAP affiliate company. All rights reserved.

35

OData Plugin
Accessing OData Offline flush()

Flush is called on a OfflineStore object to send all the requests that occurred
when offline to the server. Call when you come back online.
flush(success_callback, error_callback)
Example:
sap.OData.stores[0].flush(flush_success, flush_failure);

2013 SAP AG or an SAP affiliate company. All rights reserved.

36

OData Plugin
Accessing OData Offline refresh()

Refresh is called on an OfflineStore object to pull in the latest changes from the
backend and update the OfflineStore.
refresh(success_callback, error_callback)
Example:
sap.OData.stores[0].refresh(flush_success, flush_failure);

2013 SAP AG or an SAP affiliate company. All rights reserved.

37

Learn More Kapsel Getting Started Guide


http://scn.sap.com/docs/DOC-49592

2013 SAP AG or an SAP affiliate company. All rights reserved.

38

Demo

DEMO!

2013 SAP AG or an SAP affiliate company. All rights reserved.

39

Thank You!

Thank You for Attending!

2013 SAP AG or an SAP affiliate company. All rights reserved.

40

2014 SAP SE or an SAP affiliate company.


All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an
SAP affiliate company.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE
(or an SAP affiliate company) in Germany and other countries. Please see http://global12.sap.com/corporate-en/legal/copyright/index.epx for additional
trademark information and notices.
Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind,
and SAP SE or its affiliated companies shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP SE or
SAP affiliate company products and services are those that are set forth in the express warranty statements accompanying such products and
services, if any. Nothing herein should be construed as constituting an additional warranty.
In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related
presentation, or to develop or release any functionality mentioned therein. This document, or any related presentation, and SAP SEs or its affiliated
companies strategy and possible future developments, products, and/or platform directions and functionality are all subject to change and may be
changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment,
promise, or legal obligation to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties
that could cause actual results to differ materially from expectations. Readers are cautioned not to place undue reliance on these forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.

2014 SAP SE or an SAP affiliate company. All rights reserved.

Public

43