brought to you by the SAP Technology RIG
Ken Unnai, SAP Technology RIG
April 23rd, 2015
SAP Mobile – Webinar
Building the Best OData Services for Offline Scenario
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 2
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 SAP´s 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 forward-looking
statements, which speak only as of their dates, and they should not be relied upon in making purchasing decisions.
Legal disclaimer
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 3
Getting Ready with Offline Store – H2G
#1 - OData CRUD Crash Course
#2 - How To Implement $skiptoken
#3 - How To Implement Lightening Fast OData
Services with Exchange Table
#4 - How To Use Delta Query and
Server Side Paging with Soft State
http://scn.sap.com/docs/DOC-49861
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 4
Theory
Implementation
Demo
Getting Ready with Offline Store
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 5
Demo with offline & online
︎ ###
Theory
︎00:00 |
##:##
OData Services for Offline Store
Theory
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 6
Offline
Store
HCPms
---------------------
SMP
MobiLink Odata
Service Odata
Service OData
Service
Landscape
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 7
Offline
Store
HCPms
---------------------
SMP
MobiLink Odata
Service Odata
Service OData
Service
Problem with Offline Store Performance
Problem: Your app with offline store has some performance issue with large
volume of data. The initial creation of the store and the refresh time takes
longer than you had expected.
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 8
Offline
Store
HCPms
---------------------
SMP
MobiLink Odata
Service Odata
Service OData
Service
Solution
Server Side Paging
+
Delta Tracking/Query
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 9
What is Server Side Paging?
Split table data with $skiptoken
<link rel="next" href="TheBigCollection?$skiptoken=2000"/>
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 10
What is Delta Tracking & Delta Query?
Delta data with deltatoken
Tracking = Maintain the delta data during CUD operations
Query = Fetch the delta data via Query operation
<link rel="delta" href=”TheBigCollection?!deltatoken='20150414060630%20'"/>
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 11
Offline
Store
HCPms
---------------------
SMP
MobiLink Odata
Service Odata
Service OData
Service
Solution
*SAP Gateway
+
**Syclo xChange
Framework
*SAP Gateway 2.0, SP09+ (IW_BEP 200 SP09)
**Syclo Agentry SAP Framework Integration Foundation (SMFND 600_700)
(Requires minimum SAP NetWeaver 7.00, BASIS SP14)
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 12
Demo with offline & online
︎ ###
Theory
OData Services for Offline Store
Implementation
︎00:00 |
##:##
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 13
Implementing Server Side Paging
In an OData Query operation…
skiptoken = io_tech_request_context->get_skiptoken( ).
es_response_context-skiptoken = next_skiptoken.
1. Get the $skiptoken value in the URL
3. Set the $skiptoken value AND a cropped table
2. Do the table size calculation to crop one page
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 14
Implementing Delta Tracking
In OData Create/Update/Delete operations…
0. (Create an “Exchange Table”)
1. Capture the data change during the CUD events and
update the Exchange Table
Note: Exchange Table keeps track of “minimum” data – such as key value.
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 15
Implementing Delta Tracking
action = /syclo/cl_core_constants=>exch_action_insert.
objkey = key_value.
action = /syclo/cl_core_constants=>exch_action_update.
objkey = key_value.
action = /syclo/cl_core_constants=>exch_action_delete.
objkey = key_value.
/syclo/cl_core_exch_serv=>update_exchange( EXPORTING
iv_objkey = objkey
iv_efi_include = efi_incl_name
iv_action = action
it_data = efi_data ).
Create
Update
Delete
..and Update
Exchange Table
Enhancement
Framework
Implementation
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 16
Implementing Delta Query
In an OData (Delta) Query operation…
delta_token = lo_delta_context->get_deltatoken( ).
CALL METHOD /smfnd/cl_core_exobj_tools=>determine_delta_objkeys
EXPORTING
iv_mobile_app = ’MY_MOBILE_CONFIG’
iv_exchobj = ’MY_EXCHANGE_OBJECT’
iv_time_token = delta_token
iv_time_zone = 'UTC’
IMPORTING
eref_exch_data = delta_table.
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 17
Using $skiptoken AND deltatoken altogether
+
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 18
$skiptoken AND deltatoken by Soft State
1 2 3
Obtain Keep Split
Soft State is a new feature of SAP Gateway SP9.
Essentially it is “Stateful” session – which allows us to persist data in a user
specific session.
Soft State Soft State
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 19
Obtain
1 2 3
Obtain the entire table content & a deltatoken
as a snapshot
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 20
Keep
1 2 3
Keep the table data & deltatoken
in the soft state session
until the deltatoken is sent
Soft State
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 21
Split
1 2 3
Split the table data with $skiptoken,
the last chunk contains deltatoken
Soft State
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 22
Update & Delete Operation with Etag
Offline
Store
Etag: etagA
1
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 23
Entity Data Changed in OData Provider
Offline
Store
Etag: etagA
2 HCPms
---------------------
SMP
Odata
Service Odata
Service OData
Service
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 24
Etag Updated via Refresh
Offline
Store
Etag: etagB
3 Refresh
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 25
Adding Offline Store Queue - FAILS
Offline
Store 4
Queue
Update & Delete locally - Fails
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 26
HCPms
---------------------
SMP
Odata
Service Odata
Service OData
Service
What If the Refresh Didn’t Happen?
Queue
X
Updated & Deleted locally
Flush Offline
Store
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 27
Offline
Store
Odata
Service Odata
Service OData
Service
Error during Flush Response
offlineStoreRequestFailed
HCPms
-------------------
SMP
X
© 2015 SAP AG or an SAP affiliate company. All rights reserved. 28
Demo with offline & online
︎ ###
︎00:00 |
##:##
D E M O
OData Services for Offline Store
© 2015 SAP SE or an SAP affiliate company. All rights reserved. 29 Internal
© 2015 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 SE’s 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.