Symptom
You are using API_OUTBOUND_DELIVERY_SRV, API_INBOUND_DELIVERY_SRV to read, create, update, and delete outbound/inbound deliveries.
You combine the operations or send multiple requests at the same time by using "batch request".
If one request fails, it does/doesn't roll back which is not your expected behavior.
Environment
SAP S/4HANA Cloud
Resolution
When one request fails, it would roll back or not depends on how you setup the batch request.
If you create individual changesets for each operation by closing the changeset using the “--changeset--” statement. It means you process each operation in a separate LUW in a sequence. If one operation cannot be executed due to a business error, the other operations would still be executed.
If you would like to process all operations in one LUW, you can close the changeset only at the very end using “--changeset--“. In that case, the whole request would be cancelled and rolled back in case of an error. From a performance point of view, it is also advantageous to process everything in one changeset.
Example 1: The whole request would be rolled back in case of an error.
POST https://<host>/sap/opu/odata/SAP/API_OUTBOUND_DELIVERY_SRV;v=2/$batch
X-CSRF-Token: Token
Content-Type: multipart/mixed;boundary=batch_377f-a80c-5cf0
--batch_377f-a80c-5cf0
Content-Type: multipart/mixed; boundary=changeset_01869434-0004-0002
Content-Transfer-Encoding: binary
--changeset_01869434-0004-0002
Content-Type: application/http
Content-Transfer-Encoding: binary
PATCH A_OutbDeliveryItem(DeliveryDocument='80006048',DeliveryDocumentItem='10') HTTP/1.1
Content-Type: application/json
If-Match: W/"'0006'"
{
"Batch": "LE-B1"
}
--changeset_01869434-0004-0002
Content-Type: application/http
Content-Transfer-Encoding: binary
PATCH A_OutbDeliveryItem(DeliveryDocument='80006048',DeliveryDocumentItem='20') HTTP/1.1
Content-Type: application/json
If-Match: W/"'0006'"
{
"Batch": "LE-B2"
}
--changeset_01869434-0004-0002--
--batch_377f-a80c-5cf0--
Example 2: The whole request would not be rolled back in case of an error.
POST https://<host>/sap/opu/odata/SAP/API_OUTBOUND_DELIVERY_SRV;v=2/$batch
X-CSRF-Token: Token
Content-Type: multipart/mixed;boundary=batch_377f-a80c-5cf0
--batch_377f-a80c-5cf0
Content-Type: multipart/mixed; boundary=changeset_01869434-0004-0002
Content-Transfer-Encoding: binary
--changeset_01869434-0004-0002
Content-Type: application/http
Content-Transfer-Encoding: binary
PATCH A_OutbDeliveryItem(DeliveryDocument='80006048',DeliveryDocumentItem='10') HTTP/1.1
Content-Type: application/json
If-Match: W/"'0006'"
{
"Batch": "LE-B1"
}
--changeset_01869434-0004-0002--
Content-Type: application/http
Content-Transfer-Encoding: binary
PATCH A_OutbDeliveryItem(DeliveryDocument='80006048',DeliveryDocumentItem='20') HTTP/1.1
Content-Type: application/json
If-Match: W/"'0006'"
{
"Batch": "LE-B2"
}
--changeset_01869434-0004-0002--
--batch_377f-a80c-5cf0--
Keywords
API, API_OUTBOUND_DELIVERY_SRV, API_INBOUND_DELIVERY_SRV, Roll Back, Batch Request, Delivery, Changeset , KBA , LE-SHP-API-2CL , Interfaces for Delivery Documents (API) (Public Cloud) , How To
SAP Knowledge Base Article - Public