cancel
Showing results for 
Search instead for 
Did you mean: 

Sales Order creation via OData API calls

0 Kudos
1,539

I am trying to create Sales orders via OData API calls, by following the postman collections from this GitHub repo - https://github.com/SAP-samples/byd-api-samples/tree/main/Postman

In the request body, I noticed that there is an ItemScheduleLine array inside the Item array, but I am unable to add multiple ItemScheduleLine objects.

Request URL: https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsalesorder/SalesOrderCollection
Method: POST

{
  "Name": "Sales order test",
  "DataOriginTypeCode": "1",
  "DeliveryPriorityCode": "1",
  "SalesUnitParty": {
    "PartyID": "{{PartyID}}"
  },
  "Item": [
    {
      "ID": "10",
      "ProcessingTypeCode": "TAN",
      "FulfilmentPartyCategoryCode": "2",
      "ItemProduct": {
        "ProductID": "{{Material_ID}}"
      },
      "ItemScheduleLine": [
        {
          "Quantity": "2",
          "unitCode": "EA"
        },
        {
          "Quantity": "1",
          "unitCode": "HUR"
        }
      ]
    }
  ]
}

Question:
Is the above request body valid? Can we have multiple schedule lines for a single item object? (As it is an array as per the request body)

View Entire Topic
palu
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Srilekha,

Kindly try this below payload :

{

"Name": "Sales order test",

"DataOriginTypeCode": "1",

"DeliveryPriorityCode": "1",

"SalesUnitParty": [{ "PartyID": "PartyID" }],

"Item":

[{

"ID": "10",

"ProcessingTypeCode": "TAN",

"FulfilmentPartyCategoryCode": "2",

"ItemProduct":

[{

"ProductID": "Material_ID",

"ItemScheduleLine":

[{

"Quantity": "2",

"unitCode": "EA"

},

{ "Quantity": "1",

"unitCode": "HUR"

}]

}]

}]

}

Also, You can see a sample payload in the below blog :

https://blogs.sap.com/2020/06/29/how-to-create-service-request-and-its-item-details-using-deep-inser...

Regards,

Palani.

0 Kudos

Hi palu, Thanks for the reply.

I tried with the above request sample and got some errors. Providing "SalesUnitParty", "ItemProduct" as arrays instead of objects is resulting in a "Navigation property content for 'SalesUnitParty' has wrong cardinality" error.
Also, when I give "ItemScheduleLine" inside "ItemProduct" array, it is not recognising the "ItemScheduleLine" and throws "Property 'ItemScheduleLine' not found".

Please advise.

0 Kudos

Hi palu, any advice on why OData API is not allowing me to use the arrays(as per your payload) and throwing an error for the wrong cardinality?

Also, how do we know the different ways(request payloads) for creating a sales order? Is there any doc referring to the same? Please help!

Thank you!