cancel
Showing results for 
Search instead for 
Did you mean: 

SMP + Offline app + local data

MariusStoica
Active Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

midhun_vp
Active Contributor
0 Kudos

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

MariusStoica
Active Participant
0 Kudos

Thanks Midhun,

I'll look at it in the week-end and give you a feedback on Monday .

PS: At first glance it's not, since there are more unique keys than 177. I've added another field to the primary keys fields and I'll check.

Regards,

Marius

midhun_vp
Active Contributor
0 Kudos

Hi Marius,

Are you able to solve this issue?

Regards, Midhun

SAP Technology RIG

MariusStoica
Active Participant
0 Kudos

Somewhat.

After I added some more filds as key fields.

If I use filters with my requests, for example "readRequest("PromoItems?$filter=startswith(Product,'A')")", the response data consists in 1k entries, but when I want to read the entire 50k entries, the app crashes.

Is that ... normal ?

Thanks,

Marius

midhun_vp
Active Contributor
0 Kudos

Hi Marius,

So you mean to say that you are able to filter the data with 1k records in response but you are facing issue when the response has 50k records (I am assuming that you are doing this in offline).

What is the exception you are getting?

Could you debug the code using chrome and find in which line of code it fails. (Debugging android cordova/phonegap apps with Chrome | Gonzalo Ayuso | Web Architect)

Regards, Midhun

SAP Technology RIG

midhun_vp
Active Contributor
0 Kudos

Hi Marius

Is there any update on this issue?

Regards, Midhun

SAP Technology RIG

MariusStoica
Active Participant
0 Kudos

Hi

Sorry for the late reply.

Indeed, I can filter the 1k records, but when I try to read the entire 53k records (with no filters) the app just crashes. I get no report and no debug data also. I tries reading the debug data in Chrome Inspect and the data from Logcat (Eclipse).

In my I will never have to read the 53k items with no filters, so the use of the filter is just perfect.

I'm just baffled why the is no data in the Chrome Inspect and why the app crashes.

Thank you for your time and answers.

Marius

midhun_vp
Active Contributor
0 Kudos

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

Answers (0)