Skip to Content

How to delete all records in table with OData.remove method

May 30, 2017 at 07:43 PM


avatar image


I'm trying to remove all the records in a SAP HANA database table using OData version 2 on a SAP UI 5 application.

This is the method I am using :

I can delete a single record by specifying the index like so:



success: function(){},

error: function(){}


If I have one record in my table it will delete it. My questions is how can I easily delete all the data in my table? Do I have to use a batch operation or is there a way to select all entries to be deleted with the path itself?


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

3 Answers

Best Answer
Jun Wu May 31, 2017 at 12:46 AM

two ways:

1. create a function import, which delete all records

2.delete one by one, but they will be sent in batch as one request, so they are handled in backend as a whole.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you, I did not know it is handled as a batch by default.

Mahesh kumar palavalli May 31, 2017 at 07:09 AM

As you are using odata version v2, batch is enabled by default, you just have to loop the remove statement in loop and in the backend if the changeset is implemented, all the records can be accessed at one time.

Best Regards,e


Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you for the help!

SHADAAN QUAISER May 31, 2017 at 10:15 AM

Loop through the record of table, Create a request body object, call submit changes FOR oData model.


// Get the model
var oModel = this.getOwnerComponent().getModel();
var mParameters = {};

//Get the request data in a object by looping table.
for (var i = 0; i < oTable.getSelectedIems().length; i++) {
var requestbody = {};
requestbody.tenant_id = operationData[i].TenantId;
requestbody.order_no = operationData[i].Aufnr;

// set group id with any name
mParameters.groupId = "deleteGroup";
oModel.remove("/Wworkorderoperation", requestbody, mParameters);
//set group id to deferred groups

groupId: "deleteGroup",
success: function(oData) {

var successMsg = "All Data Deleted";
var bCompact = !!that.getView().$().closest(".sapUiSizeCompact").length;
MessageBox.success(successMsg, {
styleClass: bCompact ? "sapUiSizeCompact" : ""

error: function(oError) {
var oBody = oError.responseText,
    errorDetails = $(oBody).find("message ").text();

var bCompact = !!that.getView().$().closest(".sapUiSizeCompact").length;
MessageBox.error(errorDetails, {
styleClass: bCompact ? "sapUiSizeCompact" : ""


That's it.
Hope this works.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks for the help.