Skip to Content

oData.read() Executoin flow with v2 oData Model

Hi,

I am facing an issue with v2 (sap.ui.model.odata.v2.ODataModel) of oData Model. When I execute a read funtion of oModel, the success handler method is executed after executing the statements that are written after the read() function.

But when I use sap.ui.model.odata.ODataModel of oModel, then the success handler method of read function is executed before the statements following the read method. Meaning the request is synchronous.

Below is the read method:

oModel1.read("/PaymentDetailsSet", {
filters: filterArr1,

async:false,

success: function(oData, response) {
                len=oData.results.length;

alert(len);
},
failed: function(oData, response) {
alert("Failed to get InputHelpValues from service!");

}

can anyone tell me how to acheive the same bahaviour with sap.ui.model.odata.v2.ODataModel . The behavour with V2 is always asynchronous.

Regards,

Adren

Regards,

Adren

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 18, 2015 at 06:14 AM

    Hi Adren,

    I guess async parameter has been deprecated in v2 OData read function. So, all calls will be aynchronous.


    JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.v2.ODataModel

    However, if you want to execute set of statements after receiving the response, try using oDataModel.attachRequestCompleted(function(){}); (or) jQuery.sap.delayedCall(100, null, function(){});


    Regards,

    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 19, 2015 at 12:22 PM

    >>can anyone tell me how to acheive the same bahaviour with sap.ui.model.odata.v2.ODataModel .

    error/success callback functions or requestCompleted event + jQuery.Deferred() for more flexibility

    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.