Closed AishaFarheenPK123 closed 2 years ago
We support batch requests for generated OData V2 and V4 services as well as general OData endpoints.
If you have a question to one of the protocols please let us know.
Kind regards Alexander
Hello @newtork ,
Would like to know if updateRequest can be handled within the batch call.
When update is performed in singleton mode, it works without any issue.
service.updateEquipment(equipment).executeRequest(destination);
But, when its added onto the batch call, the update is not happening as expected. Tried by using below two ways.
updateRequest = service.updateEquipment(equipment); service.batch().addChangeSet(updateRequest).executeRequest(destination);
or
service.batch().beginChangeSet().updateEquipment(equipment).endChangeSet().executeRequest(destination);
Thanks, Aisha.
Hello @AishaFarheenPK123,
Yes, updates can be added as part of batch requests. And the examples you have added are the right way to do so.
Can you please give me more details on what is the issue you face while attempting an update via batch requests? Do you get an error or exception? Or is the update simply not happening?
Regards, Kavitha
Hi @KavithaSiva ,
We haven't encountered any error for the batch update. Its just the update was not happening.
Thank You, Aisha.
Hi @AishaFarheenPK123,
Have you made sure that you have updated the equipment
using setters before adding it to the changeset?
The service is an OData v2 one right?
Can you please check if the change set was successful using:
BatchResponse result = service.batch().addChangeSet(updateRequest).executeRequest(destination);
Try<BatchResponseChangeSet> changeSet = result.get(0);
and see if changeSet.isSuccess()
is true
?
If the requests are successful and yet the equipment was not updated, we would have to look at the actual HTTP requests being sent on the wire.
If this is the case please attach Debug logs by enabling debug logs for packages com.sap.cloud.sdk
, org.apache.http
and org.apache.http.wire
.
Please refer to this guide for details.
Regards, Kavitha
Hi Kavitha,
We have updated the equipment fields using setters before the changeset. Also, added the dependency below dependency
`
<artifactId>s4hana-api-odata</artifactId>
`
The changeset is returning a 400 status code, with below message:
Failure(com.sap.cloud.sdk.datamodel.odata.client.exception.ODataServiceErrorException: The HTTP response code (400) indicates an error. The OData service responded with an error message.)
Could you please assist here.
Thank You, Aisha
Hi @AishaFarheenPK123,
Okay, so batch request is failing. Can you please try to get more details from the exception thrown? We have to check what the S/4 system responded with. Try checking:
// run instanceof check before casting
((ODataServiceErrorException) changeSet.getCause()).getOdataError().getODataMessage();
Can you also please attach Debug logs by enabling debug logs for packages com.sap.cloud.sdk
, org.apache.http
and org.apache.http.wire
.
Please refer to this guide for details.
If yours is a spring boot application, you will have to configure the logback file to achieve the same.
If you cannot attach them here, we can also move the issue to internal GH.
Regards, Kavitha
Discussion continued in internal GH.
A bug was found and is solved in the latest version 3.68
of SAP Cloud SDK.
We would like to make a batch process with multiple patch calls to S4 system. Which cloud sdk service can be used to perform the patch operation?
Sample Url : http://example/$batch - Will be a POST call.
Sample body : --batch Content-Type: multipart/mixed; boundary=request_sep
--request_sep Content-Type: application/http Content-Transfer-Encoding: binary
PATCH Subject(Id='100') HTTP/1.1 Content-Type: application/json If-Match: *
{ "Language": "en" }
--request_sep Content-Type: application/http Content-Transfer-Encoding: binary
PATCH Subject(Id='101') HTTP/1.1 Content-Type: application/json If-Match: *
{ "Language": "fr" }
--request_sep-- --batch--