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
Hi Narasimha,
You are using different base urls (../zlistser_1_srv, .../zlister_2_srv) I think this is not allowed.
You could use integration gateway (free component that comes with SMP) to mash up these different services to create a single service as mentioned in this blog: Service Mash-up in Integration Gateway - It's Simpler Than You Think. In this example I am using different data sources but in your case you should use different odata sources to get a single Odata url then define it as backend while configuring app in SMP.
May be Dan also could give more information on this.
Regards, Midhun
SAP Technology RIG
I changed the method to define individual request for each detail record as below
Can anyone advise if this is the correct way to store? I will mark this thread answered if my testing successful.
Regards,
Murthy
Add a comment