Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert


Hello Developers,

jeff.gebo started week 5 openSAP course Developing Mobile Apps with SAP HANA Cloud Platform with


 




  • Overview of Offline OData and it's 3 important sections: Initial Download, Flush & Refresh

  • What important steps to be considered to implement for offline OData : server side paging, delta query, delta tracking

  • How to use 'Kapsel offline' template in Web IDE for developing an offline OData based hybrid application

  • Deploying and testing it on device (most preferable than emulator/simulator)

  • Various properties to be known while defining a 'defining request' in HCPms for offline capabilities


(Did he again has hair cut? :wink: )



IMO, Any enterprise level mobile application is incomplete without features like Push Notifications and Offline capabilities. As he mentioned, Business doesn't always happen where networks exist. Its really important to such capabilities in your mobile app.

My findings:

  1. Client database that gets downloaded in offline OData scenario is called as UltraLite-type Database.

  2. OData V2 is supported for offline capabilities (Also V4 but for delta queries)

  3. If you have downloaded huge amount of data on your device and now you want to make a REFRESH call, its better to enable delta queries on your OData service, so that rather than refreshing all the data , it will bring only the data which has modified after a particular 'timestamp'

  4. HCPms supports middle-tier support for OData service that doesn't have delta-enabled query capabilities.Here in this case, you will get complete data from backend to HCPms and then HCPms will compute delta based on cache keys (were stored during initial download on HCPms database) and send it to device. Not a recommended approach since it will not bring good performance

  5. It always better to enable middle-tier CACHING for generic OData collections (MASTER DATA) Check here for more info

  6. Communication from UltraLite DB to HCPms happens via Mobilink protocol over HTTP

  7. ETags: used to determine if there are any conflicts or not. Reference1

  8. OData service that doesnt support delta token use $expand to load entities and their relationships


"definingRequests" : { "req1" : "/Products?$expand=Suppliers” }

9. applyHTTPClient() method is used to call local database for requests that are mapped to the offline store.



10. Server side enforced paging ($skiptoken) and Delta-tracking/query are important features to be implemented to bring great performance in an offline OData mobile application.

Delta Tracking: maintain the delta data at backend system (like SAP Gateway, Syclo Agentry xChange Framework) during CUD operations

Query: Fetch the delta via query operation with providing deltatoken (timestamp) value

Example: http://services.odata.org/V2/Northwind/Northwind.svc/Products

     When to use delta tracking and when not

11. Offline OData constraints:

OData version 2 is supported for the offline OData feature, with several exceptions.




  • There is no support for these OData concepts:

    • Function imports.

    • ETags when using the if-match/if-none-match headers when performing LOCAL reads.

    • Modifying properties or complex type properties by addressing them in the URL.

    • Metadata annotations are not populated in the Metadata object.

    • Modifying entity relationships through entity bindings in entities.





  • The Offline OData feature has the following limitations:

    • The maximum length (MaxLength) of Edm.String key properties is 512 characters.

    • The maximum length (MaxLength) of Edm.Binary key properties is 1536 bytes.

    • The Android offline store does not support mutual authentication using X509Certificates loaded from the System KeyStore/KeyChain. It does support X509Certificates which are provided from a secure file store. The secure file store may be an SAP component, or 3rd party component, so long as the X509Certificate is supplied to the X509KeyManager when required.

    • The navigation property used for the deep insert must refer to at most one entity.








    • If you have an odata collection with a primary key which is a string, you need to make sure that maxlength field is defined for it. (image reference from Midhun's comment)




                   


12. All the collections selected for 'Offline OData entities' during creation of  a 'kapsel offline' project in webide have its information within Application constructor area in dev/devapp.js file.

13. There is always a room to modify CREATE/UPDATE UI by navigating to DetailEditMode.fragment.xml file

14. While modifying a record in the app on the android phone, keyboard doesn't appear while tapping on Name, description, release date but when i tapped on Rating Field, it appeared and could able to modify other inputs as well.

15. Defining requests are key to loading the data you need on your device.

16. Application configure initialization (.ini) file has two main sections:



    • End point configuration : determines how backend system (OData producer) should be processed by HCPms to retrieve and store the offline data, how offline DB can be prepopulated before its downloaded to client, indexing ...




[endpoint]

name=YourConnectionName

prepopulate_offline_db=Y|N|SHARED-ONLY

prepopulate_offline_db_interval=NNN

indexed_type=<namespace>.<entity type name1>: Property1A [ASC|DESC][, Property1B [ASC|DESC], …]

indexed_type=<namespace>.<entity type name2>: Property2A [ASC|DESC][, Property2B [ASC|DESC], …]

request_format=application/json;q=1,application/atom+xml;q=0.5

delta_request_format=application/atom+xml

offline_db_collation=UTF8BIN

case_sensitive_offline_db=Y|N






      • default interval for prepopulate offline DB is 1440 mins (1 day)

      • To find 'namespace' value for indexed_type, look into OData service metadata document









    • Defining requests configuration : define various characteristics of how the retrieved data for a given endpoint is managed by HCPms: data sharing, delta tracking, refresh interval, 




              
[defining_request]

name=DefiningRequestName

is_shared_data=N|Y

refresh_interval=NNN

track_deltas=AUTO|ALWAYS|NEVER

delta_token_lifetime=NNN






      • Default value for 'refresh_interval' : 15 mins

      • Default value for 'delta_token_lifetime': 72000 mins (50 days)



    • Use this .ini file only if you dont want default behavior.




17. On SAP Gateway, delta only supports passing the data back as xml when it comes to delta requests.

18. Never use $top & $skip in defining requests

19. You can have multiple offline stores in a single application, for best practice there should be one offline store per service (OData end point URL). Check here for Additional Best practices

20. Flush and Refresh activities are not performed automatically, application must explicitly call the relevant Harmonized API methods to perform these tasks.

21. Offline store supports deep insert but with limitation. Navigation property used for the deep insert must be refer to at most one entity not to a set of entities.

22. By default, an OData offline store doesn't encrypt the data it collects and stores on the device. How to enable it then?

23. Change 'Offline' Log level settings to DEBUG for more troubleshooting

Open HCPms cockpit > Logs >Log settings



Access the application, check logs under 'Logs and Traces' tab:



24. The offline store has a 16 GB limit.

25. For an offline app it is important that the URI's are routed through HCPms.

26. Offline OData plugin doesn't support Android Intel Atom emulators, use ARM one.

27. in Mobile SDK SP10, maximum of 4 offline stores can be opened at the same time.

For every other and all info check Getting Started with Kapsel - Part 10 -- Offline OData (SP09+)

You can ask your queries in discussion section of this course.


For more info,follow


SMP and HCPms: SMP Developer Center


SAP Web IDE, SAP HAT : SAPUI5 Developer Center


SAP HCP : SAP HANA Cloud Platform Developer Center


SAP HANA Cloud portal: SAP HANA Cloud Portal


Week 1: SAP Mobile strategy -openSAP-Developing mobile apps with HCP-Week 1


Week 2: SAP Web IDE deep dive-openSAP-Developing mobile apps with HCP-Week 2


Week 3: Its all about SAP Fiori Client -openSAP-Developing mobile apps with HCP-Week 3


Week 4: #HCPms helps you in mobilizing Fiori Apps -openSAP-Developing mobile apps with HCP-Week 4


Week 6: Secure your mobile-openSAP-Developing mobile apps with HCP-Week 6



8 Comments