© 2014 SAP AG or an SAP affiliate company. All rights reserved. 1
SAP Mobile - Webinar Series SMP3 OData SDK - iOS Ken Unnai Customer Experience Group SAP
Brought to you by the Customer Experience Group
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 2
SAP Mobile Platform 3.0 Enablement
SCN is our chosen channel to publish all information that you need to successfully install and run the "SAP Mobile Platform 3.0. On our Enablement 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
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 3
Disclaimer
This presentation outlines our general product direction and should not be relied on in making a purchase decision. This presentation is not subject to your license agreement or any other agreement with SAP. SAP has no obligation to pursue any course of business outlined in this presentation or to develop or release any functionality mentioned in this presentation. This presentation and SAP's strategy and possible future developments are subject to change and may be changed by SAP at any time for any reason without notice. 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. SAP assumes no responsibility for errors or omissions in this document, except if such damages were caused by SAP intentionally or grossly negligent.
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 4
SDK
OData
SMP3 SP4 / SDK SP5 http://scn.sap.com/docs/DOC-58677
! Theory
! Implementation
! Demo
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 5
Theory Demo with offline & online
︎ ###
Theory
SDK OData
SMP3 OData SDK
︎ 00:00 | ##:##
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 6
ODataStore SMP
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
OData Store
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 7
SMP Odata
Service Odata Service OData
Service
HTTP
(Delta Query is supported)
Request Online Store
Online Store - Request
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 8
Online Store
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Response SMP
Online Store - Response
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 9
OfflineStore SMP
MobiLink Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Offline Store – New MobiLink
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 10
OfflineStore SMP
MobiLink Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Working with Offline Store
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 11
SMP Odata
Service Odata Service OData
Service
HTTP Offline Store
CUD Queue
Offline Store – Disconnected
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 12
SMP Odata
Service Odata Service OData
Service
HTTP Flush Offline
Store
CUD Queue
How to sync with Flush request
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 13
Offline Store
Odata Service Odata
Service OData Service
HTTP SMP
XX
X
How to sync with Flush response
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 14
Offline Store
Odata Service Odata
Service OData Service
HTTP SMP
Error Archive
XX
X
Working with Error Archive
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 15
Offline Store
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Refresh SMP
How to sync with Refresh for local Read
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 16
Theory Demo with offline & online
︎ ###
SDK
OData
SMP3 OData SDK
︎ 00:00 | ##:##
Implementation
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 17
OnlineStore SMP
Odata Service Odata
Service OData Service
HTTP
Online Store
01 SODataOnlineStore *onlineStore = [[SODataOnlineStore alloc] !
02 initWithURL:smpOdataUrl !
03 httpConversationManager:myConversationManager]; !04 [onlineStore setOnlineStoreDelegate:self]; !05 [onlineStore openStoreWithError:&error]; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 18
OnlineStore SMP
Odata Service Odata
Service OData Service
HTTP
SODataOnlineStoreDelegate protocol
@required !
/** !
Successful delegate call after store opened !
*/ !
- (void) onlineStoreOpenFinished:(SODataOnlineStore*)store; !
!
/** !
Error delegate if store open failed !
*/ !
- (void) onlineStoreOpenFailed:(SODataOnlineStore*)store error:(NSError*)error; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 19
OfflineStore SMP
MobiLink Odata Service Odata
Service OData Service
HTTP
Offline Store
01 SODataOfflineStore�*offlineStore = [[SODataOfflineStore alloc] init]; !
02 SODataOfflineStoreOptions *options = [[SODataOfflineStoreOptions alloc] init]; !
03 options.host = serverHost; !
04 options.port = serverPort; !
05 options.serviceRoot = [NSString stringWithFormat:@"/%@", applicationId]; !
06 options.conversationManager = myConversationManager; !
07 options.storeEncryptionKey = @"MyEncryptionKey"; !
08 options.definingRequests[@"req1"] = @"/CarrierCollection"; !09 .. !
10 [offlineStore setOfflineStoreDelegate:self]; !11 [offlineStore openStoreWithOptions:options error:&error]; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 20
OfflineStore SMP
MobiLink Odata Service Odata
Service OData Service
HTTP
SODataOfflineStoreDelegate protocol
@required !
/** !
* Called when the store state changes !
*/ !
- (void) offlineStoreStateChanged:(SODataOfflineStore*) store !
" " " state:(SODataOfflineStoreState) newState; !
!
/** !
* Called if the store fails to open !
*/ !
- (void) offlineStoreOpenFailed:(SODataOfflineStore*) store !
" " " error:(NSError*) error; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 21
ODataStore SMP
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Read Entity Set
01 [store scheduleReadEntitySet:oDataQuery delegate:self options:nil]; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 22
ODataStore SMP
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
SODataRequestDelegate callback method - Response
01 - (void) requestServerResponse:(id<SODataRequestExecution>)requestExecution!
02 { !
03 id<SODataRequestParam> requestParam = requestExecution.request; !
04 !
05 if ([requestParam conformsToProtocol:@protocol(SODataRequestParamSingle)]) { !
06 id<SODataRequestParamSingle> request = (id<SODataRequestParamSingle>)requestParam; !
07 if (request.mode == SODataRequestModeRead) { !
08 id<SODataResponseSingle> responseSingle = (id<SODataResponseSingle>)requestExecution.response; !
09 if ([responseSingle.payload conformsToProtocol:@protocol(SODataEntitySet)]) { !
10 id<SODataEntitySet> myEntityset = (id<SODataEntitySet>)responseSingle.payload; !11 } else if ([responseSingle.payload conformsToProtocol:@protocol(SODataEntity)]) { !
12 id<SODataEntity> myEntity = (id<SODataEntity>)responseSingle.payload; !13 } !
14 } !
15 } !
16 } !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 23
ODataStore SMP
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
SODataRequestDelegate callback method - Request Failed
01 -(void)requestFailed:(id<SODataRequestExecution>)requestExecution error:(NSError *)error !
02 { !
03 NSString *msg1 = [NSString stringWithFormat:@"Request failed: %@", error.description]; !
04 if ([requestExecution.response conformsToProtocol:@protocol(SODataResponseSingle)]) { !
05 id<SODataResponseSingle> response = (id<SODataResponseSingle>)requestExecution.response; !
06 if ([[response payload] conformsToProtocol:@protocol(SODataError)]) { !
07 NSString *msg2 = [(id<SODataError>)[response payload] message]; !
08 } !
09 } !
10 } !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 24
ODataStore SMP
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Create
01 [store scheduleCreateEntity:entity collectionPath:@"CollectionName" delegate:self options:nil]; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 25
ODataStore SMP
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Update
01 [store scheduleUpdateEntity:entity delegate:self options:nil]; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 26
ODataStore SMP
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Delete
01 [store scheduleDeleteEntity:entity delegate:self options:nil]; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 27
Offline Store
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Refresh SMP
How to sync with Refresh for local Read
01 [offlineStore scheduleRefreshWithDelegate:self]; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 28
Offline Store
Odata Service Odata
Service OData Service
HTTP
(Delta Query is supported)
Refresh SMP
SODataOfflineStoreRefreshDelegate protocol
@required !
/** !
* Called when a refresh has finished successfully !
*/ !
- (void) offlineStoreRefreshSucceeded:(SODataOfflineStore*) store; !
!
/** !
* Called when a refresh has failed !
*/ !
- (void) offlineStoreRefreshFailed:(SODataOfflineStore*) store !
" " " error:(NSError*) error; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 29
SMP Odata
Service Odata Service OData
Service
HTTP
How to sync with Flush request
01 [offlineStore scheduleFlushQueuedRequestsWithDelegate:self]; !
Flush Offline Store
CUD Queue
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 30
SMP Odata
Service Odata Service OData
Service
HTTP
SODataOfflineStoreFlushDelegate protocol
Flush Offline Store
CUD Queue @required !
/** !
* Called when a flush has finished successfully !
*/ !
- (void) offlineStoreFlushSucceeded:(SODataOfflineStore*) store; !
!
/** !
* Called when a flush has failed !
*/ !
- (void) offlineStoreFlushFailed:(SODataOfflineStore*) store !
" " " error:(NSError*) error; !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 31
Offline Store
Odata Service Odata
Service OData Service
HTTP
SODataOfflineStoreRequestErrorDelegate protocol
XX
X SMP 01 - (void) offlineStoreRequestFailed:(SODataOfflineStore*) store !02 request:(id<SODataRequestExecution>) requestExecution!
03 error:(NSError*) error !
04 { !
05 // A. Notify the user a CUD operation was failed !
06 // B. Purge an item from the error archive !
07 } !
© 2014 SAP AG or an SAP affiliate company. All rights reserved. 32
Demo with offline & online
SMP3 OData SDK
︎ ###
︎ 00:00 | ##:##
D E M O
© 2014 SAP SE. All rights reserved.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAPBusinessObjects Explorer, StreamWork, SAP HANA, and other SAPproducts and services mentioned herein as well as their respectivelogos are trademarks or registered trademarks of SAP SE in Germanyand other countries.
Business Objects and the Business Objects logo, BusinessObjects,Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, andother Business Objects products and services mentioned herein aswell as their respective logos are trademarks or registered trademarksof Business Objects Software Ltd. Business Objects is an SAPcompany.
Sybase and Adaptive Server, iAnywhere, Sybase 365, SQLAnywhere, and other Sybase products and services mentioned hereinas well as their respective logos are trademarks or registeredtrademarks of Sybase Inc. Sybase is an SAP company.
Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services areregistered trademarks of Crossgate AG in Germany and othercountries. Crossgate is an SAP company.
All other product and service names mentioned are the trademarks oftheir respective companies. Data contained in this document servesinformational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materialsare provided by SAP SE and its affiliated companies ("SAP Group")for informational purposes only, without representation or warranty ofany kind, and SAP Group shall not be liable for errors or omissionswith respect to the materials. The only warranties for SAP Groupproducts and services are those that are set forth in the expresswarranty statements accompanying such products and services, ifany. Nothing herein should be construed as constituting an additionalwarranty.
www.sap.com