Skip to Content

SMP kapsel offline store requests offline store

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);
               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"
     ,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.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Sep 14, 2015 at 05:10 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 11, 2015 at 12:46 AM

    I changed the method to define individual request for each detail record as below

    1. function openStoreDetail(data, isApplyOffline) {
    2. var properties = {
    3. "name": "DetailOfflineStore",
    4. "host": applicationContext.registrationContext.serverHost,
    5. "port": applicationContext.registrationContext.serverPort,
    6. "https": applicationContext.registrationContext.https,
    7. "serviceRoot" : applicationContext.applicationEndpointURL+"/ZLISTSER_2_SRV",
    8. "streamParams" : "custom_header=Authorization:" + authStr + ";",
    9. "definingRequests" : {
    10. "DetailRecord1" : "/EsHeaderSet('" + record1 + "')" ,
    11. "DetailRecord2" : "/EsHeaderSet('" + record2 + "')" // and so on
    12. }
    13. };

    Can anyone advise if this is the correct way to store? I will mark this thread answered if my testing successful.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.