Skip to Content

SMP + Offline app + local data

Hi guys,

I've been working for some time with the local store and I've found an error.

After, clearing the store, opening the store and all that jazz, I read the data from the back-end (and save it on the local store) but when I try o read it again, I can't read the entire data, only a part of it.

Let me explain.

When I read the data from the back-end to fill in the local store, I receive 58k entries.

When I try to read the data of the corresponding request from the local store, I get 177 entries.

Here is the code of the 2 requests (maybe I missed something):

1. The local read in offline mode (no network access)

function readContractsRequest(param) {
var sURL = getEndPointURL() + param;


var oHeaders = {};
oHeaders['Authorization'] = authStr;
oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId;    //this header is provided by the logon plugin


var request = {
    headers : oHeaders,
    requestUri : sURL,
    method : "GET"
};
console.log("read using " + sURL);
OData.read(request, readSuccessContractsCallback, function () {alert("No contracts");console.log("No contracts data :(")});
}

2. The back-end read in online mode (network access)

function readRequest(param) {
var sURL = getEndPointURL() + param;


var oHeaders = {};
oHeaders['Authorization'] = authStr;
oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId;    //this header is provided by the logon plugin


var request = {
    headers : oHeaders,
    requestUri : sURL,
    method : "GET"
};
console.log("read using " + sURL);
OData.read(request, readSuccessCallback, errorReadCallback);
}

Is there a reason to read less entries from the local store ?

Details:

The data saved is around 6 MB, so it's not a storage issue.

If I show the data on the screen on he list I see the same numbers (58k online, 177 offline).

The other 6 similar requests on other collections work perfectly on read/write reread.

Any input is appreciated.

Thank you in advance,

Marius

offline.png (20.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 04, 2015 at 02:59 PM

    Hi Marius,

    There will not be any code difference for offline request and online request because the offline plugin is actually modifying the defaultHTTPrequest function of the datajs library. This happens when you call sap.OData.applyHTTPClient(); API in your code.

    I doubt at the primary key you defined for that collection. If the primary key value is repeating (duplicate), only one record is stored in the table. i.e if you have 5 records with 2 similar primary key values you will find only 4 records in the store.

    I would suggest you to have a look at the primary keys defined for that Odata collection.

    Regards, Midhun

    SAP Technology RIG

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Marius,

      I remember a similar scenario where faced this issue. But when I test it in a rest client I have faced the same. The rest client hanged. The issue was the the Odata response itself.

      Regards, Midhun

      SAP Technology RIG