cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

Hi,

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

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

junwu
Active Contributor
0 Kudos

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

junwu
Active Contributor
0 Kudos

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

what's the question????

Former Member
0 Kudos

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"); })

}