Skip to Content
0
Sep 10, 2015 at 08:22 AM

SMP kapsel offline store requests offline store

152 Views

Hi Experts,

I am using Kapsel oData for offline to read list and detail records using below code to create the offline stores.

    var properties = {
        "name": "ListStore",
        "host": applicationContext.registrationContext.serverHost,
        "port": applicationContext.registrationContext.serverPort,
        "https": applicationContext.registrationContext.https,
        "serviceRoot" :  applicationContext.applicationEndpointURL+"/ZLISTSER_1_SRV",
        "streamParams" : "custom_header=Authorization:" + authStr + ";",
        "definingRequests" : {
        "ListDR" :
                {
                    "url" : "/IsListSet?$filter= IvType eq ''&$expand=NavList"
                }
        }
    };
    stores[0] = sap.OData.createOfflineStore(properties);
    stores[0].open(function(){
              sap.OData.applyHttpClient();
               var url = applicationContext.applicationEndpointURL+"/ZLISTSER_1_SRV/IsListSet?$filter= IvType eq ''&$expand=NavList";
               var oHeaders = {};
               oHeaders['Authorization'] = authStr;
               var request = {
                   headers : oHeaders,
                   requestUri : rUrl,
                   method : "GET"
               };
               OData.read(request,readSuccessList, errorList);             
    }, errorOpenStore/*, options*/)

// Iterate through list and call open store for details
function readSuccessList(data, response) { var isApplyOffline = false; var resultsLength = data.results[0].NavList.results.length; for(i =0;i<data.results[0].NavList.results.length;i++){ if(i === resultsLength ) isApplyOffline = true; openStoreDetail(data.results[0].NavList.results[i].zznum, isApplyOffline); } }
// Open store for Details function openStoreDetail(lnum, isApplyOffline) { var properties = { "name": "DetailOfflineStore", "host": applicationContext.registrationContext.serverHost, "port": applicationContext.registrationContext.serverPort, "https": applicationContext.registrationContext.https, "serviceRoot" : applicationContext.applicationEndpointURL+"/ZLISTSER_2_SRV", "streamParams" : "custom_header=Authorization:" + authStr + ";", "definingRequests" : { "detailDR" : { "url" : "/EsHeaderSet('" + lnum + "')" } } }; stores[1] = sap.OData.createOfflineStore(properties); stores[1].open(function(){ if(isApplyOffline) sap.OData.applyHttpClient(); }, errorDetailStore/*, options*/) }

Store is opening for List successfully and when trying to open the store for details records (has 10 records) only one time store is opening for record, for the remaining it seems it is calling offline store.

Is it because serviceRoot is same? here is the error when I called the openStoreDetail function

"[-10001] An error occurred executing SQL statement: SELECT longValue FROM LODATA_SYS_PROPERTIES WHERE propertyID=?. Reason: -141 (ERROR) %1:LODATA_SYS_PROPERTIES."

How can I get all the details downloaded and stored in offline store.

Please suggest how to achieve this with offline store.

Regards,

Murthy