Skip to Content
Author's profile photo Knut Heusermann

OData Example: Read and Write Product Purchasing Data

SAP Business ByDesign (ByD) provides you with REST/OData access to more than 300 business objects. This blog post provides you with an roundtrip example (find – read – update) using ByD OData services.

Example Scenario

Assume we have a material with product ID “KHM4” and purchasing unit of measure “Each”. In this scenario we change the purchasing UoM to “Box” and create a quantity conversion between the units “Each” and “Box”.

Expose ByD Materials as OData Service

Open work center view Application and User Management – OData Services and create a Custom OData Service for business object Material.

Make sure you expose material properties that enable you to filter, read and update all relevant material data incl. nodes ProcurementProcessInformation and QuantityConversion. In my example I included the following elements to my Custom OData Service “khmaterial“:

  • InternalID
  • UUID
  • Description (incl. content and languageCode)
  • BaseMeasureUnitCode
  • IdentifiedStockTypeCode
  • ProcurementProcessInformation (embedded in collection Material)
    • ProcurementMeasureUnitCode
    • Status/LifeCycleStatusCode
  • QuantityConversion (created as separate collection MaterialQuantityConversion with all elements)
    • CorrespondingQuantity/content
    • CorrespondingQuantity/unitCode
    • Quantity/content
    • Quantity/unitCode

Please note: In my example I changed some property names to align with UI element names for better usability.

Furthermore, embedding the the procurement process information in the material collection simplifies read and update operations, but you cannot create procurement process information. To be able to create create procurement process information as well, you would have to create this node as separate entity.

Activate your custom OData service and note down the Service URL from the OData Editor. In my example the service URL is

If needed you can retrieve the metadata using the metadata URL$metadata


Read and Update Material Procurement Data using the Custom OData Service

Step 1: Get material data

Using the http-method GET and entity set MaterialCollection you can filter and read ByD materials and include quantity conversions:$filter=InternalID eq ‘KHM4’&$expand=MaterialQuantityConversion&$format=json

In my example I’m using the URL parameter

  • $filter=InternalID eq ‘KHM4’ to filter the materials by the internal ID,
  • $expand=MaterialQuantityConversion to include the product quantity conversions in the OData response, and
  • $format=json to use JSON as body format of the response (default is xml),

and the http-header parameter

  • x-csrf-token=fetch to get the CSRF-token to update the material in the next step.

As result ByD returns the following OData response body:

As you can see the material “KHM4” has the base unit of measure and procurement unit of measure “Each” and no quantity conversion so far.


Step 2: Create quantity conversion

Before we can change the procurement UoM to a unit that differs from the base UoM, we need to create the quantity conversion between the base UoM and the new procurement UoM. In our example the ratio should be 1 Box corresponds to 42 Each.

Using http-method POST and the parent object ID (material object ID) provided by GET-response in step 1 you can create a new quantity conversion:

Example URL:

with the http-header parameters

  • Content-Type = application/json
  • x-csrf-token = <as provided by the response header in step 1>

and body

(XBX is the ISO code for “Box”)


Step 3: Update procurement unit of measure

Now we can set the purchasing UoM to “Box” (ISO code “XBX”).

We are again using http-method POST with x-http-method “MERGE” and the material object ID provided by the GET-response in step 1:‘00163E0E25A61EE885F6DAC3F0934740’)

with http-header parameters:

  • Content-Type = application/json
  • x-http-method = MERGE
  • x-csrf-token = <as provided by the response header in step 1>

and body:


Step 4: Get the updated material data

Similar to step 1 we again get entity set MaterialCollection, filter by the material ID and expand the response by material quantity conversions:$filter=InternalID eq ‘KHM4’&$expand=MaterialQuantityConversion&$format=json

As result ByD returns the following OData response body:

As you can see the material “KHM4” now has the procurement unit of measure “Box” and a material quantity conversion node instance for the conversion between Each and Box.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Benny Huang
      Benny Huang

      Hi Knut,

      At step 1, how to set the http-header parameter? I use the firefox, the result is error:

      code	"005056952A631ED0AFCE8FF7706800FD"
      lang	"zh"
      value	"Ungültigen Token an Position 14 gefunden"

      Thanks a lot.

      Best Regards,

      Benny Huang

      Author's profile photo Jones Marshall
      Jones Marshall

      Could the Odata be used to copy a material from Template material?

      Author's profile photo Knut Heusermann
      Knut Heusermann
      Blog Post Author

      Hi Jones,

      it is not possible to use the "Copy"-function which you may know from the ByD UI via OData, but you can read materials and create materials using OData. Therefore I would conclude that you can use OData to copy a material. By the way: the same is possible using the SOAP APIs Query Materials and Manage Materials.

      Best regards,

      Author's profile photo Harun Koyuncu
      Harun Koyuncu

      Hallo Knut,

      ich habe ein Problem bei der Zeitabbuchung mit OData Services. Dazu habe ich bereits einen Blogpost erstellt.

      Ich würde mich sehr über deine Meinung und Feedback freuen.

      Hier der Link:


      Mit freundlichen Grüßen


      Author's profile photo Kory McCarthy
      Kory McCarthy


      I've read through this blog post as well as the once provided by Murthy V here:

      I've create a service to Query Outbound Deliveries based on Last Change DateTime which is working when I do not try to filter the query as shown here:

      When I then try to filter the query I receive no results, in this case I am attempting to only select the first returned record based on the last changed datetime which is highlighted in pink above.


      Any suggestions on what I may be doing wrong when filtering by datetime?

      Author's profile photo Knut Heusermann
      Knut Heusermann
      Blog Post Author

      Hi Aaron,

      Using an object query as OData function import requests like

      GET /sap/byd/odata/cust/v1/khoutbounddelivery/QueryByElements?LastChangeDateTime='2019-05-07T08:11:12.3430610Z' 

      should work. However, I see that this is not working and hence could you please open an incident to follow-up the issue.

      For the time being you could use OData requests with filter-parameter as alternative approach:

      GET /sap/byd/odata/cust/v1/khoutbounddelivery/OutboundDeliveryCollection?$filter=LastChangeDateTime ge datetimeoffset'2019-05-07T08:11:12.3430610Z'

      Best regards,

      Author's profile photo KUSHAL singari
      KUSHAL singari

      Hello Knut,

      I’m trying to create PO

      when I try to POST/PUT Bill-to-party or Buyer Party, I’m facing error “405 Method not allowed” Response – “The specified HTTP method is not allowed for the resource identified by the Data Service Request URI”


      “ParentObjectID”: “0016………………………………53C8EF3E”,
      “PartyID”: “ABC”

      I’m passing header parameters

      Content-Type = application/json

      x-csrf-token = 66……………5ndPQ==

      x-http-method = MERGE

      Accept = application/json

      Please help me



      Author's profile photo Knut Heusermann
      Knut Heusermann
      Blog Post Author

      Hi Kushal,

      as of today, the buyer party and the bill-to party are not create enabled for OData, but you can update those nodes only.

      You have two options:

      1. You could let ByD default the buyer and Bill-to party from the log-in user (requires to assign the associated employee to a organizational unit), and then update both using PATCH requests. I'm using that approach in my examples on GitHub:
      2. You submit a request to enhance the ByD Public Solution Model via Incident:

      Best regards,