cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a sales order with multiple items using OData API calls

0 Kudos
1,599

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

I am giving multiple items while creating and the request body, URL details are as follows:

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

{
  "Name": "test Sales Order",
  "DataOriginTypeCode": "1",
  "DeliveryPriorityCode": "1",
  "SalesUnitParty": {
    "PartyID": "{{Party_ID}}"
  },
  "BuyerParty": {
    "PartyID": "{{customer_ID}}"
  },
  "PricingTerms": {
    "GrossAmountIndicator": false
  },
  "Item": [
    {
      "ID": "10",
      "ProcessingTypeCode": "TAN",
      "ItemProduct": {
        "ProductID": "{{MaterialID_1}}"
      },
      "ItemScheduleLine": [
        {
          "Quantity": "2",
          "unitCode": "EA"
        }
      ]
    },
    {
      "ID": "20",
      "ProcessingTypeCode": "TAN",
      "ItemProduct": {
        "ProductID": "{{MaterialID_2}}"
      },
      "ItemScheduleLine": [
        {
          "Quantity": "1",
          "unitCode": "EA"
        }
      ]
    }
  ]
}

Although the sales order is getting created in the Business ByDesign UI, it is not populating "unitCode" for the second item and showing blank. And even when I retrieve the sales order and expand "ItemScheduleLine", the "unitCode" value is null. It works fine with a single item.


What is the root cause for this issue?

Please help!

Accepted Solutions (1)

Accepted Solutions (1)

knutheusermann
Product and Topic Expert
Product and Topic Expert
0 Kudos

I guess you are using the material P100109 of the model company in our partner demo tenants "as-is", isn't it?

If yes, then the master data record of this material does not have sales data assigned and therefore no sales unit of measure. Hence, the business object does not accept the unit "EA", because it is not allowed according the master data. The system saves the sales order with all "good" data, but keeps the status "in preparation". On the UI you find a corresponding error message as well.

The solution would be to check the master data and add the missing sales data.

0 Kudos

Thanks, Knut! Adding the sales data resolved the issue. 🙂

Answers (0)