Skip to Content
0

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

Mar 03, 2017 at 01:45 PM

380

avatar image
Former Member

Hi,

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Jun Wu Mar 03, 2017 at 04:01 PM
0

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

what's the question????

Show 1 Share
10 |10000 characters needed characters left 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"); })

}

0
Jun Wu Mar 04, 2017 at 10:25 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 06, 2017 at 04:39 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded