cancel
Showing results for 
Search instead for 
Did you mean: 

OData read, create, update, delete - callback success and error functions

Former Member
0 Kudos

Hi,

I use read/create/update/delete methods. These methods work fine because I pass in SAP debugger and all data are correctly read/created/updated/deleted in SAP from my UI5 interface values, but success and error callback functions aren't called.

Here is an example from my development :

     oKunnrSet= this.oComponent.getModel();

     oKunnrSet.read("/KunnrSet('USER')", null, null, true,

                                   function(oData, oResponse){

                                                    alert("Read successful");

                                },function(){

                                     alert("Read failed");});

If I execute my request in SAP NetWeaver Gateway, status_code = 200.

Have you an idea why success or error function are never called ?

I worked on SAPUI5 Version 1.26.9

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

try that:

oKunnrSet.read("/KunnrSet('USER')", {

     async : false,

     success : function(oData, response) {

          console.log("Read successfull");

     },

     error : function(oError) {

          console.log("Read failed");

     });

Former Member
0 Kudos

Thank you, your solution worked

Former Member
0 Kudos

You're welcome. If you take a look at the read method you'll see, that it takes only two parameters and the second one is a map.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

I have always the same problem for CREATE, UPDATE and DELETE... I try to implement the same solution that READ, but success and error function doesn't called.

Can you give me an example for create, update and delete with success and error function callback ?

Former Member
0 Kudos

Read and remove are very similar, but the create and the update request also need the data you want to store as a parameter:

create(sPath, oData, mParameters?)

    







update(sPath, oData, mParameters?)

   

example:



oModel.create("BHEintragSet", {

       "Bpartner" : oData.Bpartner,

       "Kjahr" :oData.Kjahr,

       "Hjahr" : oData.Hjahr,

       "Xdel" : ""

  }, {

       async : false,

       success : function(oData, response) {

            iSuccess++;

            sSuccessMessage += oView.getModel("i18n").getProperty("NewEntry") + ": " + oData.Kjahr + " " + oData.Hjahr + "\r\n";

       },

       error : function(oError) {

            iFail++;

            var oResponseBody = JSON.parse(oError.response.body);

            oView.getController().createMessageItem("Error", sSaveFailure,oData.Kjahr + ((oData.Hjahr)? " - " + oData.Hjahr : "") +  " : " + oResponseBody.err          or          .message.value);

  }

  });

  }

Former Member
0 Kudos

Thank you very much for your help

Update, create and delete worked now !

Answers (3)

Answers (3)

Former Member
0 Kudos

I have always the same problem for CREATE, UPDATE and DELETE... I try to implement the same solution that READ, but success and error function doesn't called.

Can you give me an example for create, update and delete with success and error function callback ?

Former Member
0 Kudos

           var oBindingInfo = {

                filters : aFilters,

                success : function (oData) {

                    jQuery.sap.log.info("Odata Read Successfully:::");

                }.bind(this),

                error: function (oError) {

                    jQuery.sap.log.info("Odata Error occured");

                }.bind(this)

            };

            if (oModel) {

                oModel.read(sPath, oBindingInfo);

            }

I hope this might help you.

Thanks.

Sarath.

Former Member
0 Kudos

This message was moderated.

santhu_gowdaz
Active Contributor
0 Kudos

Please provide your network and console after you called read().

santhu_gowdaz
Active Contributor
0 Kudos

try,

oKunnrSet.read("/KunnrSet('USER')", null, null, false,

                                   function(oData, oResponse){

                                                    alert("Read successful");

                                },function(err){

                                     alert("Read failed");});

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

Former Member
0 Kudos

Thank you for your help !