Skip to Content
avatar image
Former Member

How to delete a table records in sapui5 using function import odata services?

Hi,

How to delete a table records in sapui5 using function import odata services?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Mar 03, 2017 at 04:01 PM

    pass the IDs to function import and then delete....

    what's the question????

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      In sapui5 i am using crud operation for table, it is create and update but, it is not delete the records in a table.

      This is my code for delete operation.

      deleteFunction :function()

      { //it give complete context data assigned to row

      var contexts = sap.ui.getCore().byId("table12345").getSelectedContexts();

      if(contexts == "")

      { jQuery.sap.require("sap.m.MessageBox");

      sap.m.MessageToast.show("Please Select a row to Delete");

      }else {

      var oTable = sap.ui.getCore().byId("table12345");

      var oSelectedItem = oTable.getSelectedItem();

      var index = oTable.indexOfItem(oSelectedItem);

      var oModel1 = sap.ui.getCore().getModel('data');

      }

      var oSelectedItem = sap.ui.getCore().byId("table12345").getSelectedItems();

      var item1 = oSelectedItem[0];

      var cells = item1.getCells();

      var Zuid = cells[0].getText();

      var Oid = cells[1].getText(); //console.log(Oid);

      var oModel1 = new sap.ui.model.odata.ODataModel("/sap/opu/odata/SAP/ZSC_PROJECT_SRV", true, "username", "password");

      oModel1.remove("/zcartSet('"+Zuid+"','"+Oid+"')", null, function(oResponse){ jQuery.sap.require("sap.m.MessageBox"); sap.m.MessageToast.show("Delete Successful");

      sap.ui.getCore().getModel('data').refresh(true); },

      function(){ jQuery.sap.require("sap.m.MessageBox");

      sap.m.MessageToast.show("Delete failed"); })

      }

  • Mar 04, 2017 at 10:25 PM

    based on the code, are u really talking about function import?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 06, 2017 at 04:39 AM

    Hi sir,

    I got the answer, below is my code to delete records in a table using function imports odata services.

    var oModel = new sap.ui.model.odata.ODataModel("sap/opu/odata/SAP/ZSC_PROJECT_SRV",true, "username","password");

    oModel.callFunction("message", // function import name "GET", // http method

    {"zuid" : Zuid, "zoid":Oid }, // function import parameters null,

    function(oData, response) { jQuery.sap.require("sap.m.MessageBox"); sap.m.MessageToast.show("Delete Successful"); }, // callback function for success

    function(oError){ jQuery.sap.require("sap.m.MessageBox"); sap.m.MessageToast.show("Delete failed"); } ); // callback function

    Best Regards,

    Kalleshi.KS

    Add comment
    10|10000 characters needed characters exceeded