cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Batch oData v4 Actions in same change set

OlmoRuiz
Explorer
0 Kudos

Hi all,

I am trying to make requests to a sap s/4Hana cloud odata v4 API.

The api would be as follows.

https://api.sap.com/api/WAREHOUSERESOURCE_0001/resource

The problem is that I need to make multiple requests and I understand that the most recommended would be to use a batch call.

I am trying to invoke the following action.

/WarehouseResource(EWMWarehouse='{EWMWarehouse}',EWMResource='{EWMResource}')/SAP__self.LogonToWarehouseResource

The problem is that when making the request the two post calls are included in the same change set and the system returns the following error.

{"error":{"code":"/SCWM/ODATA_API/002", "message": "Only one warehouse number can be processed",......

By doing postman requests I have managed to do the multiple logging in one batch but separating the change sets.

I have tried to use bIgnoreETag parameter, but I get the error

Error: Not a bound action:

How could I call the batch in different changeset?

Code example:

	const oModel = this.getView().getModel("WHModel");
	const oContext1 = oModel.bindContext("/WarehouseResource(EWMWarehouse='1234',EWMResource='user1')/com.sap.gateway.srvd_a2x.api_warehouse_resource_2.v0001.LogonToWarehouseResource(...)", undefined,  {$$updateGroupId : "logonGroup"});			
	const oContext2 = oModel.bindContext("/WarehouseResource(EWMWarehouse='5678',EWMResource='user1')/com.sap.gateway.srvd_a2x.api_warehouse_resource_2.v0001.LogonToWarehouseResource(...)", undefined,  {$$updateGroupId : "logonGroup"});
				
	oContext1.execute("logonGroup");
	oContext2.execute("logonGroup");
			
	oModel.submitBatch("logonGroup").
<br>

thanks in advance.

Accepted Solutions (0)

Answers (1)

Answers (1)

OlmoRuiz
Explorer

The solution.

Insert a submitBatch call between execute calls. Thanks to the openui5 team on github.

    const oModel = this.getView().getModel("WHModel");
    const oContext1 = oModel.bindContext("/WarehouseResource(EWMWarehouse='1234',EWMResource='user1')/com.sap.gateway.srvd_a2x.api_warehouse_resource_2.v0001.LogonToWarehouseResource(...)", undefined,  {$$updateGroupId : "logonGroup"});
    const oContext2 = oModel.bindContext("/WarehouseResource(EWMWarehouse='5678',EWMResource='user1')/com.sap.gateway.srvd_a2x.api_warehouse_resource_2.v0001.LogonToWarehouseResource(...)", undefined,  {$$updateGroupId : "logonGroup"});

oContext1.execute("logonGroup");
oModel.submitBatch("logonGroup").
oContext2.execute("logonGroup");
oModel.submitBatch("logonGroup").