Skip to Content

SAP Android SDK - Offline Data Store

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-b39a-7794641e9229

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?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Jan 24 at 12:31 AM

    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-offline-odata/

    and

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

    Hope that helps,

    Dan van Leeuwen

    Add comment
    10|10000 characters needed characters exceeded

    • 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

      screenshot-1.png (89.8 kB)
  • Feb 08 at 06:47 PM

    Offline OData has some limitations which include function imports.

    The list of limitations is listed at

    Version Support and Limitations

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • Feb 11 at 08:29 PM

    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

    Add comment
    10|10000 characters needed characters exceeded