cancel
Showing results for 
Search instead for 
Did you mean: 

create and update sales order with API_SALES_ORDER_SRV using $batch with content-id in a changeset

shanmugas
Discoverer
0 Kudos
316

I am trying to update the sales order schedule lines once the sales order is created using API_SALES_ORDER_SRV using $batch. 
i am getting 500 Internal server error. in SAP S4 HANA 2023. any one faced similar issue please help.

how to get the sales order number created in the first post call to do patch in the same changeset using Content-ID?. 

Thanks.

Sandra_Rossi
Active Contributor
0 Kudos

Probably the response body tells you more, you'd better look at it/post it. Check the backend log. Then check the SAP notes (many ones).

3235882 - API_SALES_ORDER_SRV doesn't update Schedule Lines correctly - SAP for Me

3311614 - API_SALES_ORDER_SRV doesn't update Schedule Lines correctly - SAP for Me

etc.

Accepted Solutions (0)

Answers (2)

Answers (2)

gregorw
Active Contributor
0 Kudos

I've tested the S/4HANA Public Cloud API_SALES_ORDER_SRV with https://github.com/gregorwolf/bookshop-demo/blob/main/tests/s4hana/API_SALES_ORDER_SRV.http#L35 and it seems to me that you don't need a Content-ID but can add the to_ScheduleLine just directly below the to_Item.

shanmugas
Discoverer
0 Kudos
Hi @gregorw thanks for your response. In private cloud this is not working, we are not able to have desired Requested delivery date using deep insert. It is taking the header date or current date. I believe we need to update the schedule lines after creating the sales order. As we need to do it in the same API call i believe $batch could be the solution.it will be nice if some one can help here to create and update(schedule line) sales order in same API call.
gregorw
Active Contributor
shanmugas
Discoverer
0 Kudos

Thanks Sandra_Rossi for your response and time.

Sorry for the delayed response.

Below is the Error log .

Resource not found for the segment 'A_SalesOrderScheduleLine'.

I searched many note i found very few regarding $batch, i could not get any thread/note that explains how to get sales order number which is created by a post call of $batch and pass it to the next patch/post call in the same changeset of the batch call.

I could see content-id can be used for this but i could not get any sample how to update related entity.

also I could read some threads, content-id has some restriction in V2 ODATA. V4 has more capability. It will be nice if i can get some help here.

below is the payload for reference.

 

 

--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST A_SalesOrder HTTP/1.1
Content-Type: application/json
Content-ID: X10
{
"SalesOrderType": "ZOR1",
"SalesOrganization": "1281",
"DistributionChannel": "20",
"OrganizationDivision": "30",
"SoldToParty": "9000012",
"PurchaseOrderByCustomer":"ABCXYZ-12345678",
"RequestedDeliveryDate":"2024-09-04T00:00:00",
"ShippingCondition":"02",
"PurchaseOrderByShipToParty":"ABC43746213-801QO00000FHZVPYA5",
"to_Item": [
{
"SalesOrderItem": "00010",
"SalesOrderItemText":"MAT TEXT",
"Material": "ABCA045R753_2",
"RequestedQuantity": "12"
}
],
 "to_Partner": [
{
"Customer":"9000022",
"PartnerFunction":"SH"
}
]
}

--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
PATCH $X10/A_SalesOrderScheduleLine HTTP/1.1
Content-Type: application/json
{
  "SalesOrderItem":"10",
  "ScheduleLine":"1",
  "RequestedDeliveryDate": "2024-09-18T00:00:00"
}
--changeset--

--batch--