cordova-pluginssapui5sap-smp

How to handle SAP Kapsel Offline app OData conflicts properly?


I build an app that is able to store OData offline by using SAP Kapsel Plugins. More or less it's the same as generated by WEB ID or similer to the apps in this example: https://blogs.sap.com/2017/01/24/getting-started-with-kapsel-part-10-offline-odatasp13/

Now I am at the point to check the error resolution potential. I created a sync conflict (chaning data on the server after the offline database was stored and changed something on the app and started a flush).

As mentioned in the documentation I can see the error in ErrorArchive and could also see some details. But what I am missing is the information of the "current" data on the database.

In the error details I can just see the data on the device but not the data changed on the server.

For example:

  1. Device is loading some names into offline store
  2. Device is offline
  3. User A is changing some names
  4. User B is changing one of this names directly online
  5. User A is online again and starts a sync
  6. User A is now informend about the entity that was changed BUT:
    • not the content user B entered

I just see the "offline" data.

Is there a solution to see the "current" and the "offline" one in a kind of compare view?

Please also note that the server communication is done by the Kapsel Plugin and not with normal AJAX calls. This could be an alternative but I am wondering if there is no smarter way supported by the API?

Meanwhile I figured out how to load the online data (manually). This could be done by switching http handler back to normal one.

sap.OData.removeHttpClient();
sap.OData.applyHttpClient();

Anyhow this does not look like a proper solution and I also have the issue with the conflict log itself. It must be deleted before any refresh could be applied.

I could not find any proper documentation for that. Also ETag handling is hardly described in SAPUI5 and SAP Kapsel documentation.


Solution

  • The default solution is that SMP or HCPms is detecting errors by ETags. At client side there is no API to manipulate ETags in case of conflicts. A potential solution to implement a kind of diff view on the device would work like this:

    1. Show errors
    2. Cache errors (maybe only in memory?)
    3. delete the errors
    4. do a refresh of the database
    5. build a diff view with current data and cached errors

    The idea with

    sap.OData.removeHttpClient();
    sap.OData.applyHttpClient();
    

    could also work but could be very tricky and may introduce side effects. Maybe some requests are triggered against the "wrong" backend.