opensap mobile2 week 5 transcript

Upload: suresh

Post on 06-Jul-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    1/25

     

    openSAPDeveloping Mobile Apps with SAP HANA CloudPlatform

    Week 5 Unit 1

    00:00:09 Hi, welcome to Week 5 of this openSAP course on mobilizing SAP Fiori apps.

    00:00:17 This week we're going to be focusing on how we could create an offline application withwhat we call offline OData.

    00:00:24 Offline OData is a part of the HANA Cloud Platform mobile services and also from an SDKperspective,

    00:00:32 it's in our SAP Mobile Platform SDK, so the two really work together. So during this weekwe're going to see how offline OData works.

    00:00:40 That's what we'll see in this unit. And then we're going to take a look at how we could best

    develop our00:00:46 OData services to get the most out of offline. And after that, we will actually develop an

    offline OData service. OK.

    00:00:54 Then we'll look at different configuration options on the HANA Cloud Platform mobileservices for offline to get the

    00:01:03 best performance for our OData services that we're going to offline. OK. So let's get intothis unit here.

    00:01:13 You know, how offline OData works. First, the question is, why offline? Why do we needan offline app?

    00:01:19 I think the answer is pretty simple, you know. Business doesn't always happen wherethere is a network, right.

    00:01:27 And sometimes, quite honestly, even if there is one, you want to be able to work in anoffline fashion. You can see different examples here of locations that don't always havenetworks. Now

    00:01:40 on top of that, I can think of even online scenarios where this offline functionality couldhelp. I think about applications that you want to let your users browse a product catalog.

    00:01:52 OK. That product catalog, maybe you want to offline that data so that they get a betterexperience and are able to quickly go through the products.

    00:02:01 So while we're going to be focusing on offline, just know that there are options for evenonline apps to use this kind of functionality as well, to cache data on the device.

    00:02:12 OK. So on the HANA Cloud Platform mobile services, we have what we call the offlineOData service

    00:02:19 here in the mid-tier. And it works in conjunction with the Mobile Platform SDK

    00:02:25 to offline data from an OData Producer. Whether that OData is coming from SAPBusiness Suite, maybe it's coming from HANA,

    00:02:34 maybe it's coming from the HANA Cloud integration or so on, third parties, what not, right.So as long as it's in OData format

    00:02:45 and it's following the version we support, which is V2, Version 2 of OData, then we couldoffline this data. And

    00:02:53 essentially, this OData offline service is going to go out, fetch all the data that it shouldoffline, which you determine when you're using the SDK,

    00:03:05 there's an API and you list what you want to offline. It's going to fetch that data, create adatabase, and send that to our client application.

    00:03:14 And the SDK knows how to query that database, even though the SDK from an API

    perspective,

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    2/25

     

    2

    00:03:22 the developer is still using OData-type query commands and what not. And the SDK theninterprets that and sends it to the database.

    00:03:33 Now so at the end of the day, the OData service gets sent up to the device and itbecomes a local OData service there.

    00:03:42 OK, so again, your developers still work with it like it's OData. The data just happens toexist on the device.

    00:03:50 So that database is what we call UltraLite-type database. OK. This comes from theSybase days, it's well known from there.

    00:03:59 And offline OData, this service, you see here it says optimized for OData servicessupporting v4 delta queries.

    00:04:09 Well, I mentioned earlier that we support Version Now, but we do support also this pieceof Version 4 for delta queries.

    00:04:19 And this is very important for offline apps because if I offline a large amount of data on mydevice and then I want to refresh it,

    00:04:28 it's nice to have a delta-enabled query on my OData service. So I could send in atimestamp, get all the changes from the back end,

    00:04:38 and have them sent up and update my database. Otherwise I would have to go out andget all that data and send it back to do a refresh.

    00:04:48 OK. That said, we do have what we call middle- tier delta enablement for services thatdon't support delta query. And

    00:04:59 while, from the HANA Cloud Platform mobile services to the back-end OData service, westill have to get all the data for these.

    00:05:06 But we could compute a delta here in the middle tier and send that delta to the device. Soat least for even these services,

    00:05:14 we are not sending all the data, just the delta that we're able to calculate in the middle tier.We'll talk about how that works in a little bit more detail later on.

    00:05:25 OK, now on top of this as well, we offer middle- tier caching of OData collections, OK. Andwe say generic. What do we mean by generic? I like to use an example.

    00:05:37 So things like master data, OK. Things like product data or product catalog. You know,

    this data is the same for any user that wants to access it, right?00:05:47 So for all my users, I don't want to send them back to get the same data. I should be ableto cache this data here in the middle tier

    00:05:55 and send them the data that's already been cached. So we could do that with our offlineOData service.

    00:06:01 And we'll take a look at how all this works later on. That's controlled by a configurationproperty and we'll see this throughout the week.

    00:06:10 OK. Now a little closer look at our offline OData service and how it works with the SDK. Sohere we have our offline OData service

    00:06:20 on the HANA Cloud Platform mobile services. And we can see that it has its OData cache,

    00:06:27 delta enablement if it's for a service that doesn't support delta tokens, and then just

    provisioning and refreshing of the OData store here.00:06:36 So we have all this part of our OData offline service. Now, from an SDK perspective, the

    developer determines when they're developing the app

    00:06:46 what entity sets that belong to my OData service that I want to offline. And within the API,they list these out

    00:06:53 and then they're able to send that information to the HANA Cloud Platform mobileservices. It constructs a database

    00:07:01 and then loads the data into that database and sends it to our client, alright. So now foroffline stores, we're able to access the data locally within that UltraLight database.

    00:07:17 Now we could do this for both native applications, this is supported for Windows, iOS, and Android. But we could also do it for our hybrid applications as well.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    3/25

     

    3

    00:07:28 OK, and that's what, of course, we're focusing on here because Fiori being hybrid, kind ofHTML5 content, we're going to wrap it up

    00:07:36 with Apache Cordova and use our Kapsel plugins. Now this communication here is overwhat we call

    00:07:46 MobiLink protocol but over HTTP. So we're not using any proprietary communicationchannels, but the data format

    00:07:54 is in MobiLink, but again it's going over HTTP. You don't have to open any special ports oranything like this.

    00:08:02 That's the nice thing about it. OK, so let's take a look at the three scenarios

    00:08:09 that we talk about in offline. One, we want to create the initial database on the device.

    00:08:14 We have to download that data onto the device. Two is refresh. We want to update ourdata on the device.

    00:08:21 And three is flush, meaning all the changes I've made to the data, I want to flush thoseand send those to the back end.

    00:08:30 So, but first thing you do is this initial download sequence. And I just make an API call with

    00:08:37 the entity sets that I want offlined. We call these defining requests. We'll take a look at thisin more detail later.

    00:08:45 More or less it's just listing out the entity sets that I want to have offlined. Now our HCPmsreceives this,

    00:08:54 and it's got to construct that database for the OData service that we want to offline. And itdoes this by getting the metadata of that service

    00:09:04 and, from there, constructing the database. Now, at this point, it's just an empty database,right. So now we want to fill it with data.

    00:09:13 OK. So now for each defining request, we're going to loop through each one of those andwe're going to request the data from the back end.

    00:09:21 We get that data and we populate the database. Now if delta is not enabled, these deltaqueries are not enabled on this service,

    00:09:32 then what we're going to do at this point is create a bunch of cache keys that later on letus calculate a delta

    00:09:41 that we could compare against and see what's changed. So calculate this here on theserver and store that

    00:09:49 within the database of the HANA Cloud Platform mobile services so it could be used lateron when we do a refresh. OK, but we've constructed the database at this point.

    00:10:00 We notify the device. We've passed back saying, hey, here's the database file name, I'vecreated it.

    00:10:06 And it turns around and requests to download that database. The database getsdownloaded, and now it's available on the device.

    00:10:15 And at this point, you could go offline. Now that is the most simplistic scenario.

    00:10:22 There are offline config parameters that could simplify this. OK, and optimize the process,right.

    00:10:29 I mentioned earlier that we could cache data for things like master data on the mid-tier. Soif you had that configured, it would not make the request for that data to the back end.

    00:10:41 It would just use what's cached on the mid-tier. So different things to speed up theprocess and make, you know, your offline experience better.

    00:10:50 And it just depends on your scenario, what you're going to enable within the config. Nowwe will go over these offline configuration options later on in Unit 5 of this week.

    00:11:04 OK, so that was downloading the initial database sequence. Now how do we refresh?

    00:11:11 So I've maybe been offline for a couple of days, and I want to go and get all the data fromthe back end that has changed and update my local database.

    00:11:20 So I have the data that looks like it represents what's on the back end at that point in time.OK, so I send these defining requests in with the refresh API.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    4/25

     

    4

    00:11:32 And for each one of these defining requests, the HANA Cloud Platform mobile services isgoing to request the data on the back end.

    00:11:39 Now this is if delta is enabled. Well, in that case, we make the request to the back endwith the delta token

    00:11:46 which is more or less a timestamp. Now the back end then would use that to calculate allthe changes, updates, and deletes

    00:11:54 and pass that data back to the HANA Cloud Platform mobile services. Now if delta is notenabled, then HCPms has to get all the data for this service,

    00:12:07 compare it to those cache keys, and from there it could compute a delta that it could sendto the device.

    00:12:15 Now that said, just realize we do have to go back and get all the data here. OK, sodepending on the size of data,

    00:12:22 this could take a bit of time, right, so just keep that in mind. And just understand that thiswill never be as good a performance as you could have with delta tokens,

    00:12:33 if you had that enabled on your OData services. Anyway, but we can do that and it worksreally well actually with small data sets,

    00:12:40 just you've got to think about it once these datasets get larger and larger. It makes a lot ofsense then to have delta- enabled queries on those.

    00:12:51 OK, but now we have our delta. No matter if it was delta enabled or not, we've computedone on the HANA Cloud Platform mobile services.

    00:12:59 We passed this back to our client and it's able to take that information and apply thechanges to the local database.

    00:13:07 So that's refresh, that's how it works. Let's take a look at flush.

    00:13:13 In this case, we're offline. We're creating a bunch of different changes, we're creatingentries, updating entries

    00:13:21 as well as deleting some perhaps, right. And all of these values or all of these transactionswe're doing offline

    00:13:30 go into a request queue. OK. And then that queue, once we're back online,

    00:13:38 we could send it back to HCPms, and then it will go and send those requests to the back

    end. Now while you're offline as you're making changes, you know, this all gets reflectedin your local database

    00:13:51 so when you query the data, you see all the data with the changes that you've made inthese different transactions.

    00:13:59 But now we're back online, and I call the flush method and that's going to send thatrequest queue to HANA Cloud Platform mobile services.

    00:14:10 And it, in turn, is just going to loop over each request and send those to the back end.Now on the back end with OData, you have what we call ETags.

    00:14:21 And it could use these to determine if there are conflicts or not. So maybe when youofflined the data and then you updated a record,

    00:14:31 maybe since that point in time somebody else has updated a record. Well, in that case,

    that's a conflict and we don't want to overwrite what they did.00:14:38 And we could capture this using ETags. Now whether it's success or failure, this is

    reported back to HCPms for each request.

    00:14:49 And all of this information is passed back to the client. And they could query the errors inconflicts within the error archive with our API

    00:14:59 and then determine what they want to do, it's up to the developer at that point. Do theydisplay it to the user and inform them that these records weren't updated for certainreasons,

    00:15:08 maybe there were conflicts or what not. Right, so after a flush, typically you do a refreshright after that

    00:15:16 because you want to then get your database looking exactly as it does on the back end.OK, so that's again the three functionalities.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    5/25

     

    5

    00:15:25 downloading the database, refreshing it, and flushing your changes. Ok. And this is alldone when we're doing Hybrid apps using the Kapsel SDK,

    00:15:36 which is part of the mobile platform SDK. And we're going to use the OData plugin andthis enables offline support for us.

    00:15:44 OK, and it's just some simple JavaScript APIs that we're going to interact with. So veryeasy to do from Fiori-type apps, right, because they're all JavaScript-based.

    00:15:54 The first thing you do is createOfflineStore and you send in properties, which is just aJavaScript object and I'll show you what that looks like.

    00:16:02 And it just has all the different values that are needed to create this offline store - thingslike the name of the store, the host name, the port of the HCPms server

    00:16:16 and the serviceRoot, of course, whether it's using https or not. Most importantly isdefiningRequests.

    00:16:23 OK. And this is where you list out all the entity sets that you want offlined. What we'relooking at here is as simple as it gets. One single entity set.

    00:16:32 I've seen 60 definingRequests listed within this, alright. So lots of different things youcould do there, all depends on the scenario how you want to

    00:16:42 configure that. And on the next slide, we'll take a deeper look. Anyway, once we havethese properties, then we can create our store.

    00:16:50 Now at this point though, the store is just local, we haven't started the initial downloadsequence yet. We'll take a look at how we do that in just a second.

    00:16:58 But I want to take a second here to look at our defining requests. OK. And this is reallywhere you've got to put some thought into

    00:17:06 how you're going to want to get the data onto your device, and what data you want on thedevice, OK. So you can have one or more defining requests, like I said.

    00:17:17 And more often than not, it's a lot more. Like I said, I've seen up to 60 in there. OK. Andalso, for services that don't support delta tokens,

    00:17:28 you want to use $expand to load entities and their relationships. So in this example, I haveproducts where each product has suppliers.

    00:17:38 With OData, I could say give me all the products, and for each product, give me its

    suppliers. This is basically what this line is saying.00:17:45 And by using this as my defining request, it's going to construct that database with thatrelationship between products and suppliers for me.

    00:17:53 So, again, this is if our services do not support delta tokens. We would do this a differentway, if our services did support delta tokens.

    00:18:03 And that's what we have here. So for services that have delta tokens, we would rather youhave multiple defining requests for each entity set.

    00:18:12 So we say Products and Suppliers, OK. Now, but then how does it get linked up? Whatabout the relationships between them,

    00:18:23 between products and suppliers? Well, when we're constructing that database,

    00:18:29 we get the metadata of the OData service and within there it shows all the different

    relationships. So we're able to construct that and still maintain that information here.00:18:39 So, anyway, big picture, if you have delta token support, do it this way. If not, use your$expand.

    00:18:48 You could also use query parameters in our defining requests because sometimesmaybe, take this case example;

    00:18:57 I have sales orders but I only want to offline sales orders for a specific customer, OK, so.That's totally legit as well, and you could think of a lot of other use cases.

    00:19:08 There's a lot of user-based data. I only want to download and offline the accounts thatbelong to me. OK, my user.

    00:19:16 So you could have user-specific defining requests or master data defining requests.

    00:19:24 Remember I was mentioning earlier how we could cache data on the middle tier. It's thesekind of defining requests with master data that I'd want to cache.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    6/25

     

    6

    00:19:33 This user-specific data that define our defining request, I wouldn't want to cache that in themiddle tier. So in this case products and suppliers, let's cache that.

    00:19:42 User-specific sales orders that only belong to one user of my application - makes nosense to cache. Again, it's configured with some config values we'll take a look at later thisweek.

    00:19:57 OK, now I've configured all that, now I'm ready to offline my data. On my store object, Isimply call open.

    00:20:05 OK, so there's a method open, give it the callbacks whether it was error or successful. And that is what starts that initial download sequence.

    00:20:14 Of course, at this point we have to be online because we have to get the data downloadedto the device. Now I have it downloaded to the device, and I'm ready to start workingoffline.

    00:20:24 And at this point, I have to call a method to start working offline. And it's calledapplyHttpClient.

    00:20:31 This is pretty neat because what it does is first off is our Fiori-style apps using UI5,

    00:20:38 that's the JavaScript library underneath the covers that Fiori uses, is it uses an ODatalayer called data JS to access OData services.

    00:20:51 Now data JS uses an HTTP client underneath it. And that HTTP client is what sets up the

    network connection and all that.00:21:01 Well, when we call applyHttpClient, all we do is we switch the implementation of that

    HTTP client. So that now instead of being that one that sets up network connections,

    00:21:12 it sets up the connection to that local database and starts calling it, OK. Now the beauty ofthis is the way I, as a developer of my Fiori apps that are calling the OData services,

    00:21:24 it doesn't change anything in how I develop, alright. Everything in that regard stays thesame.

    00:21:31 All I have to do is set up my offline store, call applyHttpClient, and the rest stays the same.So that's what's really nice.

    00:21:40 Of course, we could call removeHttpClient later on. But that said, typically you do not wantto write an app that is sometimes online and sometimes offline.

    00:21:50 You really need to think when I'm going to write an offline app, it should be an offline app. And you should always be accessing that offline data.

    00:21:57 Not sometimes trying to access online data and sometimes offline. You'll just get into syncissues and all of this, so that's our recommendation on that.

    00:22:08 OK. Now the flush, simple flush API, call that. And that's just going to send all of thosetransactions that I've created while I was offline

    00:22:18 and send them to the back end and update the data back there. And then from there, ofcourse, it reports back with all its successes and failures

    00:22:26 and I could query that information as well. OK, refresh, very similar, same way.

    00:22:33 It's just going to send all our defining requests back, and instruct HCPms to get all thedeltas of what's changed and send that back to me.

    00:22:42 And update my local database. OK, so that said,00:22:49 that is offline OData at a high level there. I want to thank you for listening.

    00:22:54 In the next unit, we're going to take a look at how we could best develop our ODataservices to get most out of offline.

    00:23:03 So if you're going to go into one of these projects for an offline app, it's really one of thethings you need to think about.

    00:23:09 OK. Once again, thank you, and we'll talk to you soon, bye.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    7/25

     

    7

    Week 5 Unit 2

    00:00:09 Hi, Jeff here. And in this Unit 2 of Week 5, we're focusing on again offline OData.

    00:00:17 Now we're going to take a look specifically at some service development considerationsfor offline OData.

    00:00:24 So we're talking about there are certain things when we're dealing with large data setsthat we could do with our OData services to make them work best

    00:00:33 with offline OData and our offline apps. So here, we're just looking at our landscape.

    00:00:40 We have, of course, OData services, HANA Cloud Platform mobile services. And we'regoing to be able to take this data, you know, create our database,

    00:00:51 transfer it up to the device, you know over HTTP and the MobiLink protocol here.Remember HCPms uses a component that we've had around called MobiLink.

    00:01:02 OK. So we get all that data up there. But what we're seeing here is that we're offlining, asan example, large data sets here.

    00:01:11 And we're running into performance issues. We could run into timeout issues of trying tobuild that initial database.

    00:01:19 I've seen it where you start getting some timeout exceptions here and the data nevermakes it up. And not only that, but when we do our refresh of the data,

    00:01:28 it could take quite a long time because we're not supporting on the back-end deltaqueries. OK. So we're going to take a look at how we could improve this performance.

    00:01:41 OK. And these two things could be fixed or improved with server-side paging and deltatracking/queries.

    00:01:50 OK. So first let's look at server-side paging. So if you have a large data set that you'retrying to offline,

    00:02:02 the way HCPms works is it's going to make a call to that data set, that entity set you'retrying to offline and let's say there's 500,000 records in this entity set that it's trying to pullback.

    00:02:16 Now it's quite possible that it might have an HTTP timeout while trying to pull that manyrecords from the back end, OK.

    00:02:25 So if you have HTTP timeout there, you're going to end up on your client device getting atimeout exception and the data will never have been offlined and made it up to yourdevice.

    00:02:35 So to get around this issue, there is with OData services server-side enforced paging. OK.

    00:02:44 So we realize on our OData service that we don't want to make it possible to send500,000 records. For each request, we only want to send at most

    00:02:55 So I get the first 2,000 records. And you'll find at the bottom of that response

    00:03:04 will be a link to get the next 2,000. So then I get the first, and the next 2,000 in this case,as an example.

    00:03:14 And then the next 2,000 and so on until you have finally gotten all the information.

    00:03:20 So the HANA Cloud Platform mobile services, when it's offlining the data, takes thisserver-side paging into account. and will follow these $skiptoken links to continue gettingthe data

    00:03:32 until it's gotten all of it and is then able to create the offline database. In this way, we willnot run into these timeouts

    00:03:41 that might occur due to HTTP requests taking so long. OK. So, yes, with large data sets,you're going to want to support this

    00:03:50 on your OData services so that when I'm accessing all that data, it only sends back somany at a time.

    00:03:56 Now we've used 2,000 here as an example but it just depends on your data size

    00:04:02 and how much data you're passing back and forth. You might be able to do 10,000.Maybe 500 makes more sense.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    8/25

     

    8

    00:04:09 It just depends on what your data size and your network performance is. OK. So now. let'sswitch gears and talk more about the refresh.

    00:04:22 So when we trigger a refresh to update the client database, we find that it's taking far toolong.

    00:04:30 And that's because we're on our OData service, we're not supporting delta tokens or deltaqueries, OK.

    00:04:38 And with OData, we've learned that it supports these delta queries. And the whole pointbeing is, when I do a refresh

    00:04:46 I certainly don't want to get all the data, I just want to get the subset that has changedsince I last did a refresh.

    00:04:54 So I'm able to pass in the timestamp, it's what we call the delta token. OK. So there's twopieces of this.

    00:05:01 There's obviously tracking of delta. So on our back-end server, some way we need theability to track changes

    00:05:10 so that later on when somebody does send in a delta token with their query, we can takethat timestamp into account and then find all the things that have changed, right.

    00:05:22 Now if my OData service does support delta tokens, it will pass me back a link with thedelta token.

    00:05:32 So I do my initial call to the service, get all the data, and then at the bottom of thatresponse will be this delta token.

    00:05:41 So the next time I try to call this service, this entity set, to get all the data, I could alsopass in this delta token with it.

    00:05:49 And then it should go, based on that timestamp, get all the updates and creates. OK. Thatsaid, you need some way of tracking these things on the back-end system.

    00:06:00 You need timestamps of when things have been updated, created, and deleted. OK. Now,within the SAP Business Suite systems,

    00:06:11 using SAP Gateway, we do have a framework for tracking these deltas. OK. We have acouple of components, of course, we need SAP Gateway component.

    00:06:24 And then what we have from Syclo Agentry, you know, when we purchased the Syclo

    company and all their mobile apps and framework,00:06:31 they have built in a really nice framework for tracking deltas. Because, of course, all theirapps were offline, they needed this ability.

    00:06:40 And we could use this framework, and it comes licensed with SAP Gateway. You couldget this

    00:06:46 and use it to track your changes of certain entities.

    00:06:53 And then when a delta query comes in, use that framework to gather all that's beenchanged, updated, and deleted. And that way be able to send back all the deltas based onthat.

    00:07:06 OK. So that's for our SAP Business Suite systems. We have that framework.

    00:07:11 So, again, if you're mobilizing Fiori apps and large data sets, please take into account

    server-side paging00:07:20 as well as supporting delta-enabled queries with large data sets. You know, if they're

    small data sets, it's not as big an issue

    00:07:28 and HCPms does a good job of calculating those being able to calculate the deltas rightthere in the mid-tier.

    00:07:37 That said, large data sets, again, take that into account. Another thing is there are someconstraints.

    00:07:45 You know offline OData doesn't support everything that OData could do. One, with ODataand I mentioned this in the last unit, and we'll touch on it again is that

    00:07:54 OData has many different versions. Right now, we support OData Version 2.

    00:08:00 So if you have an OData Version 3 service, it will not work here with our offline OData.

    Now we are working on - the latest spec is called Version 4.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    9/25

     

    9

    00:08:11 And, like I said, delta queries are part of that spec, we do support that little piece. But Ican tell you, internally, we are working on supporting OData Version 4.

    00:08:21 But, as of today, it is Version 2. But keep a lookout in SCN and all that, and you'll seewhen we finally support Version 4.

    00:08:32 OK, now, we also do not support function imports. And that's part of the offline ODataspecification.

    00:08:43 And it probably helps to know what a function import is. Well, first off, an OData entitysupports all the CRUD operations.

    00:08:51 So, create, read, update, delete, as well as being able to query those entities. But, youknow, not all business methods fit nicely into that, right.

    00:09:01 You might have some extra method you want to have on your object like calculatebalance across all sales orders, maybe, I don't know, something like that.

    00:09:12 So this is what a function import is. It's just some extra business method that's above andbeyond what the CRUD and query operations do

    00:09:18 that you could have on your OData services. And at the end of the day, it's just customlogic.

    00:09:23 And that's why we can't offline this thing because it is custom logic. We would have to re-implement that logic on the device as well

    00:09:33 to be able to offline it and we don't know what you coded in that function import. So that'snext to impossible there.

    00:09:40 So that's not supported offline. Now there are also a couple of caveats here as well.

    00:09:47 When you create your entities for your OData service, it's essentially a table definition,right.

    00:09:55 And with any table, you have primary keys. Now if in your keys, you have a string

    00:10:03 or a binary type, you can see here Edm.String, Edm.Binary. We can only support certainMaxLength on these.

    00:10:10 So the maximum length of one of these strings is 512 in the primary key. And if it's binary,1536 bytes, OK.

    00:10:20 Now you have to specify for these key properties, the MaxLength variable. Alright, or

    attribute on these properties.00:10:31 OK. So that's required for offlining this data as well for when you're using these types in

    the key of any set that you're trying to offline.

    00:10:40 Now there's a link here, you can follow that. There are a few more odds and ends aroundwhat can be offlined and what can't.

    00:10:47 But those are the major points there I want to hit on. OK. So now I just want to do a quickdemo and show you the server-side paging

    00:10:57 as well as a delta-enabled query service. OK. So I'm going to switch over to here.

    00:11:04 And here I'm just going to go out to this NorthWind service that has a bunch of products.So we see I'm querying my product entity set here just in my REST client.

    00:11:13 I click Send. And this guy here, the way it works is it does not want to let anybody get all

    the products at once00:11:21 because it wants to prevent timeouts as well as just be nicer to the server, right.

    00:11:27 If you have 100,000 people hitting a server and it's trying to pass back performance onthere.

    00:11:37 So if we look here, if I go to preview, I can scroll all the way down to the bottom. Oops, I'll just scroll up a little bit here, sorry.

    00:11:51 OK. Down here at the bottom, you see this link "next". And then it has §skiptoken=20. Soit only passed me back twenty products.

    00:12:01 To get the next 20, I would call this. So I click that, you see it goes up to here.

    00:12:07 And now I've got the next 20. And then down at the bottom, again, it would say now go getthe next set,

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    10/25

     

    10

    00:12:15 starting at row 40. So each time, it basically says skip this many Get the next batch. OK,that's what it means there.

    00:12:23 Click that, Send, and so on. Alright. So that's how that works and, again, that's howHCPms could take advantage of this

    00:12:33 on large data sets and it will follow these Next links to get all the data so it won't do anytimeouts accessing large data sets.

    00:12:42 But you have to implement this within your OData service. It's not hard to do, it's justsomething you've got to go and implement for large data sets that you want offline.

    00:12:53 OK. Now, I'm going to take a look at another service here that is delta enabled.

    00:12:58 So here, I'm just going to click Send. And this returns back quite a few products, I could godown to the bottom.

    00:13:06 And at the end of this, you see here that it gives me a link for my deltas.

    00:13:13 OK. So my link and the URL and most importantly this delta token

    00:13:19 which is a timestamp in this case, right. So in my initial sync of the data,

    00:13:27 I'm going to call the URL that I just called. But then when I want to go and refresh it lateron,

    00:13:32 I am going to send in this link to get all the changes, OK. So I'm going to click on this guy,

    and you can see now I'm going to submit this00:13:41 with the delta token. And you can see no changes have occurred.

    00:13:46 So I get an empty response back with no more product data, alright. And it also gives meanother delta token

    00:13:56 with the timestamp of when I just did this query. So I could use that one the next time I'mgoing to query this service. OK.

    00:14:06 So, again, you can see how delta queries could work to improve our refresh performance.So that I am not having to query and get all the back-end entities

    00:14:17 and then calculate the delta in our HCPms. Have the back end do it, support delta queries

    00:14:23 within your OData services for your large data sets. Same thing with that $skiptoken.

    00:14:29 You're going to want to implement that so that we have that server-side paging and wecan prevent timeouts between HCPms

    00:14:36 and the back end while it's loading up that database with data. OK. So that's what we hadhere

    00:14:43 for Unit 2 of our offline OData. In our next unit, we're going to take a look at actuallydeveloping an offline application.

    00:14:51 And we will see how easy it is with the SAP Web IDE and the Hybrid Application Toolkit.

    00:14:58 OK. That said, thanks for listening, talk to you soon. Bye

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    11/25

     

    11

    Week 5 Unit 3

    00:00:09 Hi, Jeff here. And in this unit, we're going to take a look at creating an offline application.

    00:00:16 So we're just going to create a simple offline application using the project templates withinthe SAP Web IDE.

    00:00:25 So, again, simple but it really is a good place to start and understand how offline works.OK, with OData and all these components we've been talking about.

    00:00:37 So with that said, let's go ahead and take a look at the presentation. Like I was saying,we're going to use a project template that will generate us the project

    00:00:46 and it's called the Master Detail Kapsel Offline Application. And all we do is point at ourOData service and it takes us through a wizard of setting up

    00:00:56 the UI fields for us. And it's going to go ahead and generate all the offline code that weneed.

    00:01:03 Now, again, very simple, but it's a great first step in understanding how offline applicationswork and the code that you need to have there.

    00:01:13 OK, With Web IDE, of course, we could use our destinations we defined on the HANACloud Platform. We'll be using our NorthWind destination to point to our OData service.

    00:01:26 OK. And then we go through the template and we're just going to enter in the fields that

    we want to display within our UI that's going to be generated for us.00:01:38 Now the neat thing is, we could actually test this as a Web application and it will work in

    preview mode as a Web application.

    00:01:48 And it will still work online, OK. It will just ignore the offline pieces of the code because it'snot running

    00:01:56 an Apache Cordova container with the Kapsel plugins that are required. So you could testthis pretty easily.

    00:02:07 OK. Of course, we're going to do an offline app so when we build this with the Hybrid Application Toolkit, we've got to let it know that it needs to use the Logon Manager toonboard HCPms

    00:02:18 and then the offline OData plugin to work with the offline capabilities that come with HANA

    Cloud Platform mobile services.00:02:30 OK. Of course, to use this, we've got to be using the HANA Cloud Platform mobileservices. So we have our application configured there.

    00:02:37 We're going to continue to use the same one that we've used for our online app where wedid our simple online application and we added push plugins.

    00:02:47 We could keep using this and that's what we'll do here. But, of course, just know thisoffline functionality is possible

    00:02:54 because of the HANA Cloud Platform mobile services, so we definitely need to use that.OK, so offline project template.

    00:03:04 Here we just say we're going to create a new project from a template. We select the SAPMaster Detail Kapsel Offline Application.

    00:03:13 From there, we tell it which destination we want to use as well as the relative URL to ourOData service.

    00:03:23 OK. Then we click the Next button. And, from there, we could select the entity sets that wewant to have offlined.

    00:03:31 OK. You could select one or more here. Right, after that, it's going to take you throughconfiguring the UI, OK.

    00:03:41 And on the left-hand side, this is setting up the values that it'll display in the list. In thiscase, we're going to display products, so we're going to configure our products list here.

    00:03:52 That's what's going to show up there. And then further down, this is like a long list herethat you're going to just scroll down through.

    00:04:02 And then here we're just showing another shot of it in the Detail Section. And you'll set upwhat's going to show when I click on a product in the detail area.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    12/25

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    13/25

     

    13

    00:08:17 and I'm going to wrap it up with the Hybrid Application Toolkit and deploy that out there toone of my devices. And we'll take a look at that.

    00:08:27 OK. That said, let's go ahead and do a demo. Go over here into my SAP Web IDE.

    00:08:36 And say File>New>Project from Template And here you can see there's all sorts ofdifferent templates; you've seen these already before.

    00:08:44 You've been working with these. But now we're going to select the offline one here.

    00:08:49 I'm going to click Next and give this our Project Name OpenSAPOfflineApp Click Next.00:09:00 Now we want to go to our Service URL option down here. And I'm going to select my

    NorthWind destination.

    00:09:10 I thought I had that pasted in there, I'm just going to take that out, I'm going to go get minehere. So I could just copy this right there, paste it in.

    00:09:22 Click this button. There we go. So it was able to, through the destination, query thisservice

    00:09:28 and get all of the entity sets and different actions that belong to this OData service. OK.So that's good, and I'm just going to click Next.

    00:09:39 And I'm going to select Products and Suppliers that I want to offline. Click Next.

    00:09:47 And now here I'm going to configure my UI. I've got to first give it a Namespace; I'm just

    going to do com.sap.open.offline00:09:56 And now I'm configuring this little area up here, the search area for my list. And I'm going

    to say this is just Products.

    00:10:05 And I'm going to say which entity set I want to display here. And I could do a SearchPlaceholder that will show up there.

    00:10:14 And I could say just Search, something like that. Search Tooltip: Search Product Name,put a capital there.

    00:10:27 And I specify the Search Field, there we go, so that looks good. And now I want to list theMain Data Fields, which are these values here

    00:10:35 that are going to show up in each individual list item. Now, again, I'm going to have myproduct name show up right here.

    00:10:48 And now it says Numeric Attribute and Units Attribute, now that's just a suggestion. Thereis nothing to stop me from putting the ID there.

    00:10:57 And then underneath that the Price. OK. But, you know, what they're saying here istypically in a list, especially with products.

    00:11:05 You're going to have, you know, the price, 20 dollars, and then the currency code, the unitor maybe the weight and the unit, stuff like that.

    00:11:15 But again, that's just a suggestion, I mean these are just three fields that are going toshow up, item tile here, and then this would be the numeric attribute, underneath there isthe units attribute.

    00:11:27 It's up to you to determine what you want to put in there. And you could modify all thatcode later on anyway, right.

    00:11:34 OK. Now, the Detail Section here, I'm going to say Product Detail and I'm going to go

    ahead and I want my Description to show up.00:11:46 And maybe I want, I don't know, we can just select the Name. Again, we can modify this

    later on.

    00:11:54 Now down here, I'm going to do my OData navigation because remember a product, fromthere we could navigate it to its supplier.

    00:12:03 That's what we're talking about here, so from a product, we'd go to supplier. And this iswhere this data will show up down here.

    00:12:10 Ok, now I could display some values here, I'm going to display the Name, the City, andhow about the Country? Alright.

    00:12:20 Now the Create/Edit screen. I'm going to say I want some input. I get to create inputvalues for my key properties.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    14/25

     

    14

    00:12:29 So you could specify that so that I'll have input fields for the keys. But this depends onyour OData service.

    00:12:35 Some OData services, the back end generates the keys, OK. Now, for this, I'm just goingto say I want to go ahead and enter those.

    00:12:45 You could even generate dropdowns for some of your lists if that's applicable.

    00:12:49 Because some values within your entity sets that you create could have a dropdown list,OK. But in our case, we don't have that, we're just going to go ahead and click Next.

    00:13:03 And now she's saying it's all done. Click the Finish button. And it's going to go ahead andgenerate all the code for us.

    00:13:12 So now I have my offline application. And I could go ahead and highlight index.html

    00:13:22 And click Run. And it's just going to launch our preview mode here. And we could checkout how this application behaves and what it looks like.

    00:13:32 Give that a second. There we go.

    00:13:46 So now we have our application, we have all our data. And we just block this.

    00:13:53 It's probably hitting some offline code pieces there, we just ignore that. Anyway, so we seeall that, it looks really good.

    00:14:00 Again, I could switch resolutions here. See what it might look like on something like a

    tablet, right.00:14:06 This is the whole responsive UI that we're seeing here. And over here on the right, you

    could see the product details.

    00:14:14 As well as related supplier information. OK. So you see how we could use that template togenerate us an offline app.

    00:14:25 Right. And you can see that we can also run this application online through the previewmode. And it will, of course, ignore that offline code and enable us to do this.

    00:14:37 Anyhow, that's telling you something here, right. Later on, we're going to run this in offlinemode.

    00:14:43 But you could see the code, the OData code that is in here works both offline and online.

    00:14:50 And it's all because the offline plugins that switched the underlying http implementation for

    the OData consumption layer within UI5.00:15:03 So pretty neat that you as a Fiori developer in UI5, a developer consuming OData, you

    know you don't change your coding at all.

    00:15:13 OK. That's it for this unit. In our next unit, we're going to take this application,

    00:15:19 make a couple of modifications; I'm going to show you the offline portions of the code. Andthen we're going to deploy it to our device. OK.

    00:15:27 That's it. Thanks a lot. Bye

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    15/25

     

    15

    Week 5 Unit 4

    00:00:10 Hi, Jeff here. Welcome to this unit where we're going to take a look at deploying our offlineapplication to our device.

    00:00:20 Of course, you could do that in an emulator or simulator as well. But, again, I just like touse a device.

    00:00:26 You get much better performance when you're developing things. OK So that said, let's

    take a look.00:00:33 Now a checklist before we're going to go about deploying our application to the device is

    one, we need our Hybrid Application Toolkit Connector up and running.

    00:00:42 OK. It sets up the connection to Web IDE so that we can pull down all the contents of ourproject and then wrap them up with our Apache Cordova and add in all our plugins and allthat fun stuff.

    00:00:55 OK. So again, of course, we need Web IDE configured so it can talk to our Hybrid Application Toolkit. We've already used these things in the past, so it should be good togo.

    00:01:06 We had our HANA Cloud Platform mobile services configured with our application config.We're going to use the same one we've already had in the past, the name of that

    application00:01:16 you'll find there was com.sap.open. And then we're going to use SAP Web IDE.

    00:01:25 Of course, we're going to go and configure the device configuration settings. We're goingto pick and choose the Kapsel plugins that we want to use.

    00:01:32 And we're going to specify the HANA Cloud Platform mobile services that we're going tobe using as well for our application.

    00:01:40 OK. The two plugins we're going to use in this case are the Logon plugin and the offlineOData plugin from our Kapsel SDK.

    00:01:52 Alright. So deploying this thing, really simple, we've done it before. We just right-click onindex.html, Run, Run on, and then you pick what you want to run on.

    00:02:02 Whether it's a simulator or device, iOS or Android. OK. And again, what happens is we

    pull down all the content from our project.00:02:14 We start our Apache Cordova build, we pull in the plugins we're using. And then wedeploy it out to our simulator or device. OK

    00:02:25 Again, at the end of the day, you have a full- fledged application that could run offline. Alright. Now we're going to test this.

    00:02:36 So first thing is we're just going to onboard the application. So we're just going to enter inour credentials here, onboard.

    00:02:43 And then, from here, we are going to start that initial download sequence once the data isdownloaded onto the device, so it has that local database.

    00:02:53 The data will be displayed as we see here. OK. And now, at this point, we could click anitem

    00:03:00 and at this point we could go into airplane mode and start testing that way. One thingabout the iOS simulator, there's no airplane mode.

    00:03:09 So another reason I like to work with the device. OK. So we click one of these items andthen go to the detail screen. And

    00:03:21 by testing all that, again, you do all this in airplane mode. And you can see that it's alloffline and the data has been persisted on the device

    00:03:29 based on the defining requests that you have entered in when creating the offline store.OK. So now let's look at the other operation. So we just did the read operation.

    00:03:41 Now let's look at the create operation here. You can see this little plus icon.

    00:03:47 So that gets generated by that offline application template. Just click that. And it brings upa UI screen with the input fields where you can enter in your data.

    00:03:59 OK. So we type all that in. Now just one thing; you can see that this contains a date string.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    16/25

     

    16

    00:04:05 And it's an input field. Now that's the only thing that's kind of tedious here, you have toenter it in in an OData format

    00:04:11 that they're expecting, that you can see here. Of course, we could change this, we couldadd a calendar plugin

    00:04:19 or a date picker, so somebody could use that. It would definitely be a better usability wayto do it.

    00:04:25 But this is what the template generates and you can enter in the date like so. Now, fromthere, we hit the Save button of course.

    00:04:34 And that's going to persist it to our local store. OK But, at this point, it has not beenpushed back to the server.

    00:04:42 So the data is saved locally. Now we could go and test this.

    00:04:49 And make sure that the data is not yet on the server, right. So we could go and just openup a browser, and we could call our OData REST service there

    00:04:58 and I like to use Chrome because it formats the data pretty nice. And we just submit arequest or OData service to do a Git on all the products.

    00:05:08 And we can see if that new product is there, and you'll find that it has not been persistedthere yet. And it's just telling you that offline is working. OK

    00:05:19 So again the new entity is not here on the back end. Now, update is very similar, but we're just going to go and click one of our products.

    00:05:31 We're going to be able to go into edit mode by clicking the little pencil icon here for Edit.Change some values, click Save. And

    00:05:41 everything is persisted locally. And we could test it by going to a browser and calling aREST service for the product's entity and seeing if anything has changed there.

    00:05:52 OK. You'll find that that updated product, the changes you made, are not yet reflected. Alright OK. Same thing with the Delete. You can pick an item, alright, then you've got theDelete icon.

    00:06:07 And, again, once you've done that you go back and check and make sure your changesaren't there. OK, so. Not your changes, but make sure your product is still there because ithasn't been deleted yet.

    00:06:20 So, now, after all that's been done, we've created a bunch of offline transactions. Theseare all being stored in the request queue.

    00:06:29 Now it's time to do our Flush and Refresh and send these changes back to the back-endserver with the flush.

    00:06:38 And then after that we'll do a refresh to get all the latest changes that other users mighthave made. OK. So the way this application works is that there is a single button

    00:06:48 for doing this, but in the code - and I'll show you this in a little bit - it actually calls the flushfunction first on our offline store.

    00:06:58 If that's successful, then it will call the refresh for you. OK, alright. So we just click that,take a few moments.

    00:07:09 And then all the changes have been synchronized with the back end. And, from there,now we can go run our REST client again,

    00:07:16 make sure what we deleted has been deleted, what we created is there and the changeswe made are there as well. Alright.

    00:07:25 So, and that's how offline works. So remember there's just the three main stages, right.You've got:

    00:07:30 You've got your initial download, you've got your flush of the local transactions that you'veput in the request queue,

    00:07:36 and then the refresh to synchronize all the data that other users have been changing aswell. OK. Of course, you could also deploy to a device, as I've been saying.

    00:07:48 You just select device, whether it's Android or iOS. In this case, it's just showing iOS. And,like I said, that's what I prefer to do just because it's so much faster.

    00:08:00 OK, so that said, I'm going to show you a little bit of the code and a little bit of a demo

    here.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    17/25

     

    17

    00:08:06 So we're going to go over to our Web IDE that I have opened here in my Chrome browser.

    00:08:14 And we have our project, and I what I want to do first is, you remember I was talking aboutdefining requests.

    00:08:22 So, by default, this application when the template generates the defining request and itcreates a defining request for each entity that you choose to be offlined.

    00:08:35 And you might remember I was talking about with defining requests that if your back enddoesn't support delta tokens,

    00:08:43 that you want to use a $expand to load that data in. OK So we want a single definingrequest in our case.

    00:08:50 So we have products, and each product has a relationship to its supplier. So when youhave that kind of relationship, you could change it,

    00:09:00 use a $expand, so that at the same time that I'm loading my products in, I'm also gettingeach product's supplier data

    00:09:10 that it has a relationship to. So I'm going to change this product's defining request.

    00:09:15 I'm going to say $expand= And then we're just going to say

    00:09:23 supplier like so. So we're loading in the supplier relationship that each product has.

    00:09:31 Now because I did that, I could just go ahead and delete this defining request, the load in

    the suppliers.00:09:40 OK. So I have the one for products and it's going to, in turn, load all suppliers.

    00:09:46 And it's going to create that relationship on the database between products and suppliers.Now, if we are using OData services that supported delta tokens,

    00:09:59 well, in that case, we would want to do what was already shown there. You want to have adefining request for each of the entities.

    00:10:07 And the relationship between them will be created based on what is read in the metadatabecause the metadata also defines these relationships between entities.

    00:10:19 OK. But this looks good. Now this is inside of what's the devapp.js

    00:10:25 where there's some high-level variables created here. If we go into devlogon.js,

    00:10:32 it's here where you'll find the code that interacts with these plugins. OK. You'll find the

    code that starts the Logon plugin.00:10:40 And then you'll find the code from there that kicks off the offlining process and does the

    flush and refresh as well.

    00:10:48 So if I go down through this, we'll see that here's where I'm interacting with the Logonplugin and kicking off that process.

    00:10:56 Now if Logon is successful, it calls this function. So let's go ahead and search for that.

    00:11:02 It's right here. So, and after the Logon succeeds, then it's going to go out and start the

    00:11:09 opening up of the offline store. OK. So you can see here is another function it calls onsuccess

    00:11:15 for starting this offline store process, so we'll scroll down to here. And it looks very similarto the code I've shown in

    00:11:25 earlier slides here, but you can see I'm setting up a properties variable here. And withinthis is where you're setting up your defining request

    00:11:34 and all those other properties I was showing you. And then you create an offline storeobject right here.

    00:11:41 OK. Create offline store, alright, and we pass in those properties. And then the actualdownload sequence of that offline store is started when you call open.

    00:11:52 Now, just a reminder, depending on the size of your data, this could take a while, right.

    00:12:00 I mean if you're downloading hundreds of megabytes of data, be prepared that this, yourapplication will be waiting to be downloaded, maybe up to 10 minutes, right.

    00:12:09 It just depends on what your offline scenario is and how much data is being downloaded.OK, but on success, you can see that it calls this function.

    00:12:18 And then on error this one. Now I wanted to show you now we could go and look for flush

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    18/25

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    19/25

     

    19

    00:16:32 go into airplane mode, so you can see that. Alright. Go back to my application.

    00:16:39 And we'll see this is still working, you know, because we are in offline mode, we see theairplane displayed.

    00:16:48 what I'm going to do is just make a small change here, I'm going to go into Edit mode. Andwe'll try to name this

    00:16:58 Chocolate Milk, if I could spell it right. There we go, Chocolate Milk, Done, looks good.

    00:17:12 I'm going to click my Save button. Save was successful, I navigate back.00:17:18 And now we see Chocolate Milk displayed here. Just to show you, I'm going to re-run my

    service out here that I'm going against.

    00:17:28 We could search for the word Milk, and we see that it is still Milk, alright. OK. Maybe Iwant to go and delete one of these items, I'm going to delete this Pink Lemonade.

    00:17:42 I never liked the Pink Lemonade, so it's gone. Things are looking good. Now, let's go outof here, go back

    00:17:51 and connect back to the network. And now I'm ready to sync my changes.

    00:17:58 I'm going to hit Refresh here. We're going to let that go. The actual flush of the changeshappens very quickly, OK.

    00:18:07 So I deleted that. And I'm going to hit refresh.

    00:18:14 I'm going to search for Milk again. And we see that now it says Chocolate Milk. OK00:18:21 Let's see if we could find our Pink Lemonade in here. And there is no Pink Lemonade. OK

    00:18:29 So that's looking good. So now we see our app,

    00:18:34 worked offline, made some changes, went back online and then was able to flush thosechanges

    00:18:42 and refresh the data on our device here. OK So that's great. You can see how easy it is tocreate one of these offline applications

    00:18:53 with our template. Now that template is just sample code.

    00:18:59 There's a lot of different ways you could develop your own Fiori apps to support offlineand there's different APIs you could use there to

    00:19:09 develop your own application, right. But it's a great place to start and for you tounderstand

    00:19:16 how offline works and create a quick app and get it up and going. Now, of course, youcould do the same thing with a native app.

    00:19:24 You could write an iOS or an Android app and go that route as well. Or even a Windowsphone app, right?

    00:19:32 So lots of different options. And I hope you enjoyed this unit on getting our app running onour device here.

    00:19:40 Now in the next unit, we're going to take a look at different offline configuration propertieswe could use to get better performance based on our offline scenario.

    00:19:51 So a lot of different things you could do on the server side with an offline config file. Andwe'll take a look at that in the next unit.

    00:19:58 Thanks a lot. Talk to you then. Bye

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    20/25

     

    20

    Week 5 Unit 5

    00:00:10 Hi, Jeff here. And in this unit, we're going to take a look at the offline configurationpossibilities on HANA Cloud Platform mobile services.

    00:00:18 So there's a lot of different ways you could configure your offline database that gets sentto the client devices to behave.

    00:00:28 Different things, you could cache data and what not. So we're going to take a look at these

    options that could help you tune00:00:35 to get the most out of the offline OData service and get the best performance for your

    scenario. OK. So we've already learned that on the HANA Cloud Platform mobile services,

    00:00:45 we have this offline OData service. And it's what goes ahead and constructs us the initialdatabase and sends it to our client devices.

    00:00:54 It also has the ability to take an offline request queue that gets sent from the client andthen send those back to the back-end server.

    00:01:04 And then give the responses back to our client devices. Then, of course, the ability to doour refreshes.

    00:01:11 So we receive a refresh call from one of our devices. And we go and get all the deltas thathave changed since whenever it was last refreshed

    00:01:21 based on some timestamp there. OK, but there's a lot of other options we could do forcaching data

    00:01:30 as well as creating things like indexes on properties of some of the tables that exist withinthat offline database.

    00:01:38 So that's one of the things we can configure, as you can see. A lot of times when you'researching across a table with many rows,

    00:01:47 it makes a lot of sense to have indexes on it. It'll speed up performance and, within thisconfiguration, we can specify

    00:01:54 which of our properties in our OData service we want to have indexed. You can configurewhat data gets cached on the server.

    00:02:03 You can go so far as changing the default delta determination behavior. We'll take a lookat those things in more detail going forward.

    00:02:13 Now all of these offline configuration properties, you just enter these things into a file. Usesome sort of a text editor.

    00:02:21 And once you're done with that, you're able to upload it to your application configurationyou have defined out there on the HANA Cloud Platform mobile services

    00:02:29 using the admin UI. OK. Now this is only required if you want to change the defaultbehavior

    00:02:36 of the offline store service. So, if you're happy with that and it meets your scenario, youdon't have to do any of this, right.

    00:02:43 You don't have to upload any file or anything like that. That said, in a lot of scenarios, itmakes a lot of sense to take some of this into account.

    00:02:53 OK. Now this offline configuration file is broken up between end-point configurations and

    then more granular defining request configurations.00:03:03 Now with your application, typically you have one end point, one back-end OData service.

    00:03:10 But, that said, it's possible to have multiple of these end points defined, OK. And, for eachone, then you could have many defining requests

    00:03:21 and you could configure all of these different things. Now at the end-point configurationlevel, that's where you could set your indexes

    00:03:29 on the entity properties that you want indexes on. Where you will configure what data willbe allowed in the database that's initially sent to the device, OK.

    00:03:41 So, and then you go into a little more detail here. So this database that gets constructed,

    00:03:49 you could say whether you want the data loaded inside the HANA Cloud Platform mobileservices. Or you might send an empty database to the client

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    21/25

     

    21

    00:03:58 which then you would refresh from there and load the data in that way. More typical, Ithink you're going to have the data prepopulated

    00:04:08 on the HANA Cloud Platform mobile services but you have different options becausemaybe some of this data you don't want to have it loaded

    00:04:15 in the middle tier there because you don't want to wait for it to load that data maybe youwant to get that database faster to your users and then let it refresh from the device.

    00:04:26 Anyway, different options there, and you pick what matches your scenario. So you couldalso of course configure if the data is cached or not.

    00:04:36 Refresh interval on the cached data. OK, so you might have some data there and whatthe HANA Cloud Platform mobile services will do is when this interval

    00:04:47 is met, whatever time value you put in, it will go out and then refresh and call the back-endOData service and then refresh that cached data at the HANA Cloud Platform mobileservices level.

    00:05:01 OK. Now the defining request configuration. This is where we can configure, again,whether data is cached or not.

    00:05:08 So this is a more granular level. The refresh interval on that cached data and whether wewant to change the default delta tracking behavior.

    00:05:17 Typically, I don't see a lot of need for changing that but there might be scenarios where

    that makes sense. Default behavior is to take deltas into account, and typically that's whatyou'd want to do. OK

    00:05:32 So, the offline configuration possibilities are a little bit more. The application configurationfile and looking at the end-point configuration, OK.

    00:05:42 So our end-point configuration is made up of a name of our end point, and your defaultend point, the back-end connection, is just the name of your application configuration.

    00:05:53 And in our case, that is com.sap.open So we would give it that name.

    00:05:58 Now if I created any secondary end points for my application, then I would use the namethat I gave those secondary end points.

    00:06:06 But in our case, we just have a single one. So it's just com.sap.open Then we couldspecify if we want to prepopulate the offline db.

    00:06:15 If we want to change the default behavior. Default behavior is yes, we want to prepopulateit on the HANA Cloud Platform mobile services.

    00:06:22 Or we could set it to no, that would send an empty database. Or maybe we only want toprepopulate it with the shared type of data, with that master type of data that we have.

    00:06:33 OK, index_type This is where you could specify different indexes we want on our ODataproperties.

    00:06:40 We'll take a look at an example of this but it's made up of listing out the namespace ofyour OData service, then a period,

    00:06:48 and then the entity type, and then the properties that we want indexes on. And you canmark them as ascending or descending here.

    00:06:58 OK. Now also request_format. Depending on the back-end OData service, the default is torequest the data in json format.

    00:07:09 But some of these only support xml. So we requested to get it back as atom+xml here. OK

    00:07:19 On top of that for delta requests, you could change those to request the data in xml aswell

    00:07:29 and/or json here. Because some, for example, on SAP Gateway, their delta only supportspassing the data back as xml

    00:07:38 when it comes to delta requests. So that's why we've got to be able to have that propertythere to configure it

    00:07:44 so that we could call back-end SAP systems with OData delta tracking.

    00:07:51 OK, now defining request configuration options. So now we're at a more granular levelwhere we're below the end point now and we could set

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    22/25

     

    22

    00:08:01 configuration on each defining request we have. And, again, we use the name of ourdefining request.

    00:08:06 This would be the same name that you set up in your properties job descript object whenyou're creating your defining request

    00:08:16 when you're coding the application, so it'd be the same name. You mark whether it's goingto be shared or not.

    00:08:23 Again, if it's product data, I'd say yes, it makes a lot of sense. Default is no though.refresh_interval: How often do I want to go and refresh this cached data

    00:08:33 that's going to be on the database with the HANA Cloud Platform mobile services. Also,whether we want to change the default behavior of how deltas are tracked.

    00:08:43 OK. And then also delta_token_lifetime. You know, sometimes maybe if one of these deltatokens is weeks old,

    00:08:51 you have that timed out so that it's ignored and next time that device does a refresh, it justgets all the data, things like that.

    00:09:00 OK. So those are the things for the defining request. Now here's an example of what oneof these configuration files might look like.

    00:09:09 We'd have our end point. We would specify our prepopulate db settings here, how oftenwe're going to refresh things. And then maybe a couple of

    00:09:20 what we see here are some indexes that we're going to define on our database that we'regoing to send over to the clients.

    00:09:27 Then for each defining request, we would go in and say whether we want shared data ornot. If we do say shared data, yes here.

    00:09:35 Then you could see that we're entering in a refresh interval, OK. Then you could changethis to a value that makes sense to you. This is in seconds.

    00:09:48 OK. From here, we're going to take that file and upload it into our application configurationarea.

    00:09:55 You can see when we go in and configure our application configuration, there is an OfflineConfiguration area.

    00:10:01 I could go here now, select my back-end connection here and then import the offline

    configuration for it, OK.00:10:15 OK. So now let's take a look at a demo. I'll show how we could edit one of theseconfiguration files and upload it to the HANA Cloud Platform mobile services.

    00:10:24 Let's go ahead and do that. First thing I want to do is show you my configuration file.

    00:10:29 All I've done here is create my end-point configuration and then my defining requestconfiguration.

    00:10:36 And this is very simple. I only have one defining request that I have within my application.If we go up here, what we're saying is this is our name,

    00:10:46 which is going to be com.sap.open This is the settings for our offline db

    00:10:53 if we only want to prepopulate it with shared only data. And I'm just setting the refresh rateof that to be,

    00:11:01 that's basically in seconds, so 15 minutes. Setting too here a couple of properties, OK.00:11:08 And these properties, you might be wondering where this comes from. So

    ODataDemo.Product and then, of course, the name of the properties.

    00:11:17 Let's go ahead and look at the metadata of our OData service here. And that will make alittle more sense.

    00:11:23 So that OData demo comes from the Namespace of our service here. You see that, it'sODataDemo right there.

    00:11:32 And then the product is the name of the entity type that we want to set an index on. Sothat corresponds to a table, right.

    00:11:40 This would correspond to the entire database, and this would correspond to a table withinthe database.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    23/25

     

    23

    00:11:46 And then the property would be Name, which corresponds to a column, right. So I'mpicking Name and Description.

    00:11:52 And if I go back now to my file, we see that, you know, product, and then I'm setting anascending index on this.

    00:12:02 And then I'm setting here another index on these two columns here with descending ondescription.

    00:12:11 OK, and now, then I go down to my defining request area here. And I'm just saying yes,this is shared data for the Products defining request.

    00:12:19 And Products just comes from the name of the defining request we gave it within our codewhen we were creating that offline store.

    00:12:27 And then a refresh rate we could specify on this. OK, so we're prepopulating all the data

    00:12:33 only for shared data. Of course, in this case, we only have shared data. So I only haveone defining request, but just to give you an idea of the things you might see here.

    00:12:43 OK, so now if we go over to our mobile services here. I'm going to go to com.sap.open

    00:12:53 Click Configure. And over here, we see we have Offline Configuration.

    00:12:59 And now I could see within this, that I have this back-end connection here with this name.Now just to briefly go to Backend.

    00:13:09 So if we go over here, you could see I have one back end that we've created for the back-end URL.

    00:13:15 OK. And you can see the connection name, that's where that comes from. So the URLyou put in for the default back end

    00:13:23 will take on the name of your application configuration. Now you could see here, though, Icould create more of these.

    00:13:29 So that's why you could have multiple end points here. So just go back here to offlineconfiguration.

    00:13:37 And I'm going to go ahead now and import that file. Click Browse, select my offline file.

    00:13:45 Click Upload. Now it's going to upload it to the server here. You can see it's uploadedsuccessfully.

    00:13:52 And now I could even click these links and see which defining requests I have andwhether they're shared and how often they're going to be refreshed.

    00:14:02 You can see the Client Indexes here. And I can look at the entire configuration as well. OK

    00:14:12 So that's how we configure this and how you're able to tune the offline service to give youthe best performance based on your scenario.

    00:14:23 Alright. Thank you for listening. This is going to end our unit here as well as this weekwhere we focus on offline OData.

    00:14:36 So what have we learned here over this past week? We've learned that we could createonline and offline applications using

    00:14:45 HANA Cloud Platform mobile services on top of using our SAP Mobile Platform SDK.

    00:14:52 We could create these for hybrid applications or for native applications. And we saw how

    easy it is using the SAP Web IDE00:15:02 and the Hybrid Application Toolkit to quickly create an offline application. And it was a

    great way for us to learn how offline works

    00:15:11 and to get an application going within the framework of our openSAP course. Then wesaw how, with offline OData, we could configure it using that application configuration file

    00:15:24 to upload it to the HANA Cloud Platform mobile services and get the best performancebased on our offline scenario.

    00:15:32 OK. I hope it was a good week for you, I hope you learned a lot. And thank you forlistening.

    00:15:39 Next week, we're going to take a look at SAP Mobile Secure and what it offers us to

    00:15:47 do different things to secure our apps, you know, using what we call Mobile Place, to

    hosting our apps in an app store for your employees.

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    24/25

     

    24

    00:15:56 As well as taking a look at how we could create different applications for Fiori and have itactually build us a Fiori Client.

    00:16:04 Anyway, lots of neat stuff. I look forward to hearing from you next week. Thanks forlistening. Goodbye

  • 8/18/2019 OpenSAP Mobile2 Week 5 Transcript

    25/25

     

    www sap com

    © 2015 SAP SE or an SAP affiliate company. All rights reserved.No part of this publication may be reproduced or transmitted in any formor for any purpose without the express permission of SAP SE or an SAPaffiliate company.SAP and other SAP products and services mentioned herein as well as theirrespective logos are trademarks or registered trademarks of SAP SE (or anSAP affiliate company) in Germany and other countries. Please seehttp://www.sap.com/corporate-en/legal/copyright/index.epx#trademark foradditional trademark information and notices. Som e software productsmarketed by SAP SE and its distributors contain proprietary softwarecomponents of other software vendors.National product specifications may vary.These materials are provided by SAP SE or an SAP affiliate company forinformational purposes only, without representation or warranty of any kind,and SAP SE or its affiliated companies shall not be liable for errors oromissions with respect to the materials. The only warranties for SAP SE orSAP affiliate company products and services are those that are set forth inthe express warranty statements accompanying such products an d services,if any. Nothing herein should be construed as constituting an additionalwarranty.In particular, SAP SE or its affiliated companies have no obligation to pursueany 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 pl atformdirections and functionality are all subject to change and may be changed bySAP SE or its affiliated companies at any time for any reason without notice.The information in this document is not a commitment, promise, or legalobligation to deliver any material, code, or functionality. All forward-lookingstatements are subject to various risks and uncertainties that could causeactual results to differ materially from expectations Readers are cautioned

    http://www.sap.com/corporate-en/legal/copyright/index.epx#trademarkhttp://www.sap.com/corporate-en/legal/copyright/index.epx#trademarkhttp://www.sap.com/corporate-en/legal/copyright/index.epx#trademark