cancel
Showing results for 
Search instead for 
Did you mean: 

kapsel offline odata plugin got only one record for entityset

former_member183212
Participant
0 Kudos

Hi ALL

     i am working on sap kapsel hybird app develop, my odata plugin version is com.sap.mp.cordova.plugins.odata 3.8.1 "OData",  my smp server version is SMP3.0 SP7.

    now i have encoutered a weird problem, my gateway service can provide an entityset with multiple records, however when i created offline odata, i only got one record!  i used the same codes to retrive the rmtsampleflight demo gateway service, i can get multiple records.

Is my own odata service wrong? but when i comment the offline odata plugin, it can got multiple records. any advice wounld be helpful!

thanks

Billy

Accepted Solutions (1)

Accepted Solutions (1)

midhun_vp
Active Contributor
0 Kudos

Hi billy,

Could you have a look at this discussion. Which talks about a similar problem:

Regards,Midhun

SAP Technology RIG

former_member183212
Participant
0 Kudos

Hi Midhun,

   thanks for your advice, it works.

Regards,

Billy

Answers (2)

Answers (2)

former_member183212
Participant
0 Kudos

you see

"definingRequests" : {

                        //"FlightCollectionDR" : "/FlightCollection"

                        "EE_COMMUNICATION_SETDR" : "/EE_COMMUNICATION_SET"

                    }

when i changed it to

"definingRequests" : {

                        "FlightCollectionDR" : "/FlightCollection"

                        //"EE_COMMUNICATION_SETDR" : "/EE_COMMUNICATION_SET"

                    }

and changed the Backend URL in smp sever to /sap/opu/odata/iwfnd/rmtsampleflight/,  i can get multiple records. so maybe the gateway service i created missing something?


however, you see the function function readModel() {  if i use it to retrieve data directly, i can get multiple records even with my own gateway service.


so what should do with my gateway service , if you want to use offline odata plugin?

thanks,

Billy

former_member183212
Participant
0 Kudos

here is some codes.

function openStore() {

                if (!haveAppId()) {

                    return;

                }

                console.log("store.open called");

                var properties = {

                    "name": "OfflineStore",

                    "host": appContext.registrationContext.serverHost,

                    "port": appContext.registrationContext.serverPort,

                    "https": appContext.registrationContext.https,

                    "serviceRoot" :  appId,  //appId,

                    "customHeaders" : {

                        "X-SMP-APPCID" : appContext.applicationConnectionId,

                        "Authorization" : "Basic " + btoa(appContext.registrationContext.user + ":" + appContext.registrationContext.password)

                    },

                    "definingRequests" : {

                        //"FlightCollectionDR" : "/FlightCollection"

                        "EE_COMMUNICATION_SETDR" : "/EE_COMMUNICATION_SET"

                    }

                };

                console.log("appContext");

                store = sap.OData.createOfflineStore(properties);

               

                //var options = {};

                store.open(openStoreSuccessCallback, errorCallback/*, options*/);

                console.log("store.open called2");

            }

            function haveAppId() {

                if (!appContext) {

                    alert("Please register with the SMP Server before proceeding");

                    return false;

                }

                return true;

            }

            function openStoreSuccessCallback() {

                console.log("Store is OPEN.");

                sap.OData.applyHttpClient();  //Offline OData calls can now be made against datajs.

                readModel();

            }


            function readModel() {

                var oModel;

                var url = appContext.applicationEndpointURL;

                var oHeader = {"X-SMP-APPCID":appContext.applicationConnectionId};

                if (appContext.registrationContext.user) {

                    oHeader["Authorization"] = "Basic "+btoa(appContext.registrationContext.user + ":" + appContext.registrationContext.password);

                }

                oModel = new sap.ui.model.odata.ODataModel(url, true, null, null, oHeader);

                sap.ui.getCore().setModel(oModel);

          }