0

Can anyone please let me know the syntax for the DELETE batch operation using SAP UI5. I have done the insert batch operation. Its working fine. But delete batch operation is not working.

My INSERT Batch operation syntax

       update_entry.YEAR = year;
       update_entry.COUNTRY_ID = country;
       update_entry.CUSTOMER = name;

var batch_single =   insert_model.createBatchOperation('/customers',"POST",update_entry);   
                    batch_changes.push(batch_single) ;
insert_model.addBatchChangeOperations(batch_changes);
        insert_model.submitBatch(function() {
                                    update_success == "successful" ;}, function() {
                                    update_success == "unsuccessful";}, true);
                                insert_model.refresh(); 

I have modified the above code for the DELETE batch operation as below

    var batch_single =   insert_model.createBatchOperation('/customers',"DELETE",update_entry);

But the above syntax is not working. Could anyone help me with the issue.

Thanks Sathish

2 Answers2

1

As opposed to the create operation, you'll need to pass the ID to the delete operation and not "entry":

var batch_single =   insert_model.createBatchOperation('/customers(1234)',"DELETE");`
mlenkeit
  • 211
  • 1
  • 4
0

I think changing from "POST" to "DELETE" will work, because you need a DELETE-request to push data to your backend.

First, check out this thread: SAPUI5 - Batch Operations - how to do it right?

I think the main-difference is your entity in createBatchOperation "/customers" - I think you have to change it to your service (e.g. "/sap/opu/odata/sap/MY_SERVICE/?$batch"). I found that then the batch is triggered, starting in this sequence:

  • 1) /IWBEP/IF_MGW_CORE_SRV_RUNTIME~CHANGESET_BEGIN: SAP Proposal EXIT.
  • 2) /iwbep/if_mgw_appl_srv_runtime~delete_entity. (n-times)
  • 3)/iwbep/if_mgw_core_srv_runtime~changeset_end: SAP Proposal COMMIT WORK.

Second dont use '' and "" in the same statement (during createBatchOperation) - always use the same (if possible).

insert_model.createBatchOperation("/customers","POST",update_entry); 

Regards, zY

Community
  • 1
  • 1
dotchuZ
  • 2,621
  • 11
  • 39
  • 65