Symptom
When creating two different sales orders in one change set using sap/opu/odata/sap/API_SALES_ORDER_SRV/$batch the call fails with an error message such as: "Resource not found for segment 'A_SalesOrderType".
Environment
- SAP S/4HANA Cloud
Cause
This is expected system behaviour when trying to create two different sales orders in one change set as the MV45A program can't process more than one sales order at the same time.
Resolution
As per the SAP Help documentation Operations for Sales Order (A2X) you can only create or process a single sales order per change set of a $batch OData request.
To create multiple orders in one $batch OData request ensure that a different changeset for each operation is inserted into the payload making sure to initiate the change set and close it after each request as per the below sample example:
--batch_mybatch
Content-Type: multipart/mixed; boundary=changeset_mychangeset1
--changeset_mychangeset1
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_SalesOrder HTTP/1.1
Content-Type: application/json
Accept: application/json
{
"SalesOrderType": "OR",
"SalesOrganization": "0000",
"DistributionChannel": "00",
"OrganizationDivision": "00",
"SalesGroup": "",
"SalesOffice": "",
"SalesDistrict": "",
"SoldToParty": "Test",
"PurchaseOrderByCustomer": "Test",
"CustomerPurchaseOrderType": "",
"CustomerPurchaseOrderDate": null,
"TotalNetAmount": "1000",
"TransactionCurrency": "GBP",
"SDDocumentReason": "",
"ShippingCondition": "01",
"CompleteDeliveryIsDefined": false,
"ShippingType": "",
"HeaderBillingBlockReason": "",
"DeliveryBlockReason": "",
"IncotermsClassification": "FOB",
"IncotermsTransferLocation": "Free On Board",
"IncotermsLocation1": "Free On Board",
"IncotermsLocation2": "",
"IncotermsVersion": "",
"CustomerPaymentTerms": "0001",
"PaymentMethod": "",
"AssignmentReference": "",
"ReferenceSDDocument": "",
"ReferenceSDDocumentCategory": "",
"OverallSDProcessStatus": "B",
"TotalCreditCheckStatus": "",
"OverallTotalDeliveryStatus": "C",
"OverallSDDocumentRejectionSts": "A"
}
--changeset_mychangeset1--
--batch_mybatch
Content-Type: multipart/mixed; boundary=changeset_mychangeset2
--changeset_mychangeset2
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_SalesOrder HTTP/1.1
Content-Type: application/json
Accept: application/json
{
"SalesOrderType": "OR",
"SalesOrganization": "0000",
"DistributionChannel": "00",
"OrganizationDivision": "00",
"SalesGroup": "",
"SalesOffice": "",
"SalesDistrict": "",
"SoldToParty": "Test",
"PurchaseOrderByCustomer": "Test",
"CustomerPurchaseOrderType": "",
"CustomerPurchaseOrderDate": null,
"TotalNetAmount": "1000",
"TransactionCurrency": "GBP",
"SDDocumentReason": "",
"ShippingCondition": "01",
"CompleteDeliveryIsDefined": false,
"ShippingType": "",
"HeaderBillingBlockReason": "",
"DeliveryBlockReason": "",
"IncotermsClassification": "FOB",
"IncotermsTransferLocation": "Free On Board",
"IncotermsLocation1": "Free On Board",
"IncotermsLocation2": "",
"IncotermsVersion": "",
"CustomerPaymentTerms": "0001",
"PaymentMethod": "",
"AssignmentReference": "",
"ReferenceSDDocument": "",
"ReferenceSDDocumentCategory": "",
"OverallSDProcessStatus": "B",
"TotalCreditCheckStatus": "",
"OverallTotalDeliveryStatus": "C",
"OverallSDDocumentRejectionSts": "A"
}
--changeset_mychangeset2--
--batch_mybatch--
See Also
Keywords
KBA , SD-SLS-API , API , SD-SLS-API-2CL , API (Public Cloud) , Problem