cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Android SDK - Offline Data Store

0 Kudos

Hi,

I'm trying to enable offline OData in an Android Application. I created the application via the creation wizard in Android Studio and everything worked fine with the online OData. Then I followed this guide:

https://developers.sap.com/hk/tutorials/cp-sdk-android-wizard-app-offline.html#db432312-0f49-4553-b3...

but I encounter this problem: on the first launch the offline data store in created according to the backend data, nevertheless If I try to edit a record and then closing the app, when i open it again the edited record is still there even if there was no change on the backend data, like the app is not actually refreshing the offline store but just showing a saved copy of it.

Can anyone help?

Accepted Solutions (0)

Answers (3)

Answers (3)

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

I would suggest examining the ErrorArchive after attempting to do an upload. I assume it will contain an entry on the failed upload.

There are further details on this topic at

Step 5: Display ErrorArchive details

and

Accessing the ErrorArchive

If you wish to discard the local change that is failing to be synced to the backend, the following topics describe how to do this.

Reverting an Error State

It is also possible to try this out using ILOData (an interactive tool used to issue OData commands in a console). This is described in the following link.
Step by Step with the SAP Cloud Platform SDK for Android — Part 6c — Using ILOData

Hope that helps,

Dan van Leeuwen

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

Offline OData has some limitations which include function imports.

The list of limitations is listed at

Version Support and Limitations

0 Kudos

I managed to send updated data to the backend thank you. Now i have the same problem exposed in the original question: when the updated data is sent to the backend if i maually prevent any modifcation on backend data after the sync offline data still show the offline modifications. If I perform a second download of the offline data the "et_entityset" table sent by the backend contains the correct data while the offline data store contains the old data with the offline modification that i stopped. What can be the cause of this phenomenon?

Thank you very much

0 Kudos

I'll try to make it more clear because maybe i'm not so good to express myself in english, I am sorry:

when i open the OfflineDataProvider for the first time a call to the backend is peerformed to retrieve the data.

Then if I call the UpdateEntity method on the Offline service container my offline data is successfully updated.

If then I perform a sync my locally updated data is correctly pushed to the backend.

But if i perform a sync but on the backend side something goes wrong and the backend data is not correctly updated, with the download operation after the upload i would expect to see my offline data restored to the ones i had before my update operation on the local data. So if:

Local Data = A ; Backend Data = A

then

Local Data = B ; Backend Data = A

Sync

Upload: Local Data = B --> Backend Data = still A because something was wrong

Download: Backend Data = A --> Local Data = i would expect to restore it to A but it stays = B.

Dan_vL
Product and Topic Expert
Product and Topic Expert
0 Kudos

The tutorial mentioned above does not include the steps necessary to perform an upload of the locally modified changes.

Here are a few more resources that do cover this topic.

https://blogs.sap.com/2018/10/15/step-by-step-with-the-sap-cloud-platform-sdk-for-android-part-6-off...

and

https://github.com/SAP/cloud-sdk-android-offline-odata

Hope that helps,

Dan van Leeuwen

0 Kudos

Thank you! This was really helpful!

I have another question tough: I am trying to perform an update operation offline in the first place and then to sync my on premise system. When i call the Update... method on my online data provider i catch the http call on my ECC system through a breakpoint. Otherwise when i call the Update operation on my offline data provider and the run the sync operation nothing happens. Am I using this feature in a wrong way?

Thank you

BWomelsdorf
Advisor
Advisor
0 Kudos

Angelo - I wouldn't expect to see any network traffic when you do the local update. That's why we call the feature "offline" OData. But if the local update was successful you should see network traffic when you do the sync, as long as the offlinedataprovider.upload() method is being called. Did you put the code to update data to the backend as Daniel suggested? You can find this in https://blogs.sap.com/2018/12/08/step-by-step-with-the-sap-cloud-platform-sdk-for-android-part-6a-sy....

0 Kudos

Hi Britt,

That's the point. I created a Function Importo on my ECC systen via the SEGW transaction. Then i generated the proxy classes and the method highlighted in screenshot 1 was generated.

This is the declaration of my online and offline service container and data provider

Online:

myDataProvider = new OnlineODataProvider("ZTESTANGELOSRVEntities", serviceURL + "/" + connectionID , myOkHttpClient);
myServiceContainer = new ZTESTANGELOSRVEntities(myDataProvider);

Offline:

myOfflineDataProvider = new OfflineODataProvider(url, offParam, myOkHttpClient, null, delegate);

myOfflineServiceContainer = new ZTESTANGELOSRVEntities(myOfflineDataProvider);

When i call the updateLifnr method on my online service container everything is fine. On the other hand when i do the same on the offline service container and then perform a sync nothing happens and i get the following error.

com.sap.cloud.mobile.odata.offline: [AsyncTask #4] [-10028] Error at URL position 1: "UpdateLifnr" is not an entity set in entity container "Z_TEST_ANGELO_SRV_Entities"

What am i doing wrong?

Thank you in advance