on 03-03-2017 1:45 PM
Hi,
How to delete a table records in sapui5 using function import odata services?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
based on the code, are u really talking about function import?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
pass the IDs to function import and then delete....
what's the question????
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"); })
}
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.