Skip to Content
Technical Articles

SAP Business ByDesign – OData API Examples

The SAP Business ByDesign (ByD) provides REST/OData APIs to access ByD business objects, reports and data sources:

  • The OData API for Reports is tailored for remote access to pre-processed and formatted analytical data (reports). The remote application may extract a ByD analytical model as a cube incl. semantics like key figures, language-dependent texts and aggregated data.
  • The OData API for Data Sources is designed to extract analytical raw data (data sources) in flat tables, free of redundancies from ByD.
  • The OData API for Business Objects is designed for UI-driven access to ByD business objects. A UI-like remote application or system interactively queries, reads, creates, updates, deletes or performs actions on ByD business objects and business documents. Using the work center “Application and User Management – OData Services“, key users are empowered to decide which business objects, nodes, elements and actions are exposed via OData API.

You find more information about ByD APIs in blog post SAP Business ByDesign – API Overview.

Where do I get OData examples?

To get some hands-on experience using SAP Business ByDesign OData APIs you find a repository of API Examples on GitHubSAP Business ByDesign – API Samples.

The GitHub repository provides sample ByD Custom OData Services for currently 44 business objects and 6 Postman collections with more than 600 example OData requests. The Postman collections illustrate hands-on how to access master data, business documents and analytical data in context of ByD business processes with a focus on ByD OData APIs.

All sample Postman collections are tailored to SAP Business ByDesign Partner Demo Tenants (Full scope US) with preconfigured and loaded sample data provided by SAP.

Nevertheless you can use the Postman collections and sample Custom OData Services in other ByD systems as well, if you adopt Postman environment variables and Postman requests according the business configuration and master data of your ByD system.

The GitHub repository contains the following Postman collecions:

  • Analytics – Data Sources: Extract analytical raw data (data sources) from the ByD.
  • Analytics – Reports: Extract pre-processed, aggregated and formatted reporting data from ByD.
  • Master Data: Access ByD master data objects using APIs
    • Organizational Structure
    • Material
    • Service Product
    • Sales Price
    • Business Partner
    • Customer
    • Supplier
    • Employee and Position
    • Code lists
  • Reference Scenarios: Run ByD business processes using APIs to get insights how to create, change and read involved business documents and how to create business document relationships to achieve a meaningful document flow
    • Lead to opportunity to quote
    • Order to cash for services
    • Procure to pay for services
    • Field service and repair
    • Procure to stock
    • Sell from stock
    • Drop shipment
    • Make to stock
    • Clear due items using bank statements
  • Projects: Create, change and read cost collecting projects and customer projects
    • Cost collection project with task hierarchy
    • Cost collecting project with project team and work
    • Customer project with planning data
    • Sell project-based services (sales order > project > project time recordings)
  • Sales and Commerce Scenarios: Run ByD sales and commerce processes using APIs to get insights how to create, change and read involved business documents and how to create business document relationships to achieve a meaningful document flow.
    • Sell from stock with external payment
    • Create customer invoices with external payment
    • Customer return to stock
    • Pre-confirm payments using clearing house statements
    • Confirm payments using bank statements
    • Create sales orders using a nested create, batch and node-by-node
    • Create sales orders with attachments
    • Create sales orders with externally provided prices, discounts and surcharges

Please check the description of the respective Postman collection for further details.

How to run API examples?

The easiest way to run an API sample scenario would be using a SAP Business ByDesign Partner Demo Tenant (Full scope US) with preconfigured and loaded sample data provided by SAP.
The following example is based on such a tenant and I am running the scenario “Master Data – Service Product (write)“:

  1. Install the API sample package “Master Data and configure your ByD system following the instructions in  chapters “Download and Installation” and “Configuration” of the GitHub repository readme file.
  2. Open the Postman Runner and select the collection “Master Data, the collection folder “Service Product (write)and the environment “Master Data“:
  3. Click on “Run Service Product (write)” and see the process flow:

For more detailed analysis you can open the Postman Console to log detailed traces or simply execute the requests one-by-one in the Postman collection itself.

By the way:
The sample Postman collections may serve as well as approach to create meaningful data along process chains to prepare a ByD system for demo purposes, or to run regression tests by processing end-to-end business processes.

Blog Posts with further Examples

31 Comments
You must be Logged on to comment or reply to a post.
  • Update of API sample package “End-to-End Scenarios”:

    • Sample OData service tmserviceorder.xml enhanced by service order lifecycle status
    • Scenario “Drop Shipment”: SOAP request to create third-party delivery notification replaced by corresponding OData request.
    • Scenario “Procure to Stock”: Request “Accept supplier invoice exception” removed (not needed after ByD update to SP02)
  • Thanks Knut Heusermann  for this very helpful blog.

    We have a doubt about Sales Order Item Pricing:

    We are building an integration which fits on “Selling Services Scenario” provided on the API Sample Package.

    Since our Services are not price defined, we tried to create a SalesOrder indicating the price on each Item, but we got an error.

    We also tried to update the SalesOrder when it is created, and since we get no error, the price is not updated.

    Could help us with that? We saw that it is possible to do on SOAP, but for this integration we are building, REST is a Must.

    Thank you.

  • Update of API sample package “Projects”: Added a sample Custom OData Service and corresponding Postman OData requests to create and read project time recordings.

  • Hello.

    Using the provided POST request “Update fulfilled quantity” in the “Field Service and repair” Scenario, we are getting the following error:

    The server has not found any resource matching the Data Services Request URI.

    Has anyone ever found a solution for this?

    Thank you in advance.

     

     

    • Hi Marc,

      I’m using Postman environment variables in the OData URL. Those variables are either values provided or are populated by previous requests.

      In your request the environment variable “ServiceConfirmationItemScheduleLineObjectID” seems to be empty or invalid. Please enter a valid value for variable “ServiceConfirmationItemScheduleLineObjectID” in your Postman environment or run the OData requests of folder “Field Service and Repair” in the given sequence such that the variable is populated by request “Get service confirmation” (see Postman request test script of request “Get service confirmation”).

      Best regards,
      Knut

  • Hi Knut,

    We’ve got a requirement to create Customer Invoice Requests directly via OData rather than via Sales Orders. Looking at the PSM, it should be possible to create a Customer Invoice Request by setting Business Process Variant Type to 3 (for a manual request), the CustomerInvoiceProcessingTypeCode to CI and buy setting the buyer party and sales unit party (as well as items of course).

    I’ve taken your example web service for Selling Services and have imported the customer invoice request service into my BYD tenant and then altered the service to expose the relevant fields and objects.

    However when I try to create a request with a POST, I find that the Sales Unit Party is read only. I am able to set the Business Process Variant Type, and the CustomerInvoiceProcessingTypeCode but the sales unit party ID is read only.

    Is this why you’ve used a sales order and then released the order, and then get the invoice request from the sales order ID, because you ca’t create an invoice request directly?

    Greg

    • Hi Greg,

      I’m using sales orders because of the scenario that I realized (for example incl. deliveries and ATP check); using sales orders was not intended as workaround for creating invoice requests directly.

      You can change the sales unit party of customer invoice requests by a Patch on the corresponding resource of the SalesUnitPartyCollection. The fact that you can’t create the sales unit party with the invoice request directly is a gap in our PSM for OData.
      However, if you dig deeper you will find out that there are more invoice request elements not yet create/update enabled or missing and hence as of today you can’t create an external customer invoice request using OData.
      For that reason, I would suggest to use the SOAP API Manage Customer Invoice Requests to create external customer invoice requests. This API provides you with the possibility to create and change invoice requests incl. prices and external payments, and you can furthermore trigger invoicing directly.

      Here is an example for an invoice request using API Manage Customer Invoice Requests:

      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global" xmlns:glob1="http://sap.com/xi/AP/Globalization">
          <soapenv:Header/>
          <soapenv:Body>
              <glob:CustomerInvoiceRequestBundleMaintainRequest_sync>
                  <BusinessDocumentBasicMessageHeader>
                      <!-- Enter message header UUID for idem potency! -->
                      <!-- <UUID>?</UUID> -->
                  </BusinessDocumentBasicMessageHeader>
                  <CustomerInvoiceRequest actionCode="01" itemListCompleteTransmissionIndicator="false">
                      <ObjectNodeSenderTechnicalID>HDR_1</ObjectNodeSenderTechnicalID>
                      <BaseBusinessTransactionDocumentID>{{CustomerInvoiceRequestID}}</BaseBusinessTransactionDocumentID>
                      <Name>My customer invoice with external payment</Name>
                      <!-- SettlementPriorityCode: 
                       1 = Immediate - create custom invoice, 
                       2 = Urgent - stop if a down payment exists
                       3 = Normal - save invoice request with status "to be invoiced" -->
                      <SettlementPriorityCode>1</SettlementPriorityCode>
                      <ReferenceBusinessTransactionDocumentID>{{InvoiceRequestExternalReference}}</ReferenceBusinessTransactionDocumentID> <!-- External Reference -->
                      <BuyerParty>
                          <InternalID>{{CustomerID}}</InternalID>
                      </BuyerParty>
                      <SalesUnitParty>
                          <InternalID>{{SalesUnitID}}</InternalID>
                      </SalesUnitParty>
                      <CashDiscountTerms>
                          <!-- 1001 = immediately net; 1006 = 10 days 5% -->
                          <Code>1001</Code>
                          <!-- <FullPaymentEndDate>2019-05-30</FullPaymentEndDate> -->
                      </CashDiscountTerms>
                      <PaymentControl>
                          <!-- PaymentFormCode: 04 = Direct Debit, 20 = External Payment -->
                          <PaymentFormCode>20</PaymentFormCode>
                          <PaymentReferenceID>{{PaymentReferenceID}}</PaymentReferenceID>
                          <!-- used to clear the payment -->
                          <PaymentReferenceTypeCode>5</PaymentReferenceTypeCode>
                          <PaymentServiceSubscriberID>{{CompanyID}}</PaymentServiceSubscriberID>
                          <PaymentServiceCustomerID>{{CustomerID}}</PaymentServiceCustomerID>
                          <ExternalPayment actionCode="01">
                              <!-- <UUID>?</UUID> -->
                              <!-- Bank Account ID from UI screen My Bank >> View All >> Bank Accounts -->
                              <HouseBankAccountKeyInternalID>{{HouseBankAccountID}}</HouseBankAccountKeyInternalID>
                              <!-- House bank: 1000644 - ABN AMRO Bank -->
                              <PaymentTransactionReferenceID>{{PaymentTransactionReferenceID}}</PaymentTransactionReferenceID>
                              <DocumentDate>{{DocumentDate}}</DocumentDate>
                              <ValueDate>{{ValueDate}}</ValueDate>
                              <Amount currencyCode="USD">220</Amount>
                          </ExternalPayment>
                      </PaymentControl>
                      <PricingTerms>
                          <!-- PricingProcedureCode: PPGP02 = Standard Gross Procedure, PPSTD1 = Standard Procedure -->
                          <PricingProcedureCode>PPGP02</PricingProcedureCode>
                          <CurrencyCode>USD</CurrencyCode>
                      </PricingTerms>
      <!-- Invoice item | service product | tax code derived by system -->
                      <Item>
                          <BaseBusinessTransactionDocumentItemID>10</BaseBusinessTransactionDocumentItemID>
                          <!-- ReceivablesPropertyMovementDirectionCode: 1 = Invoice item, 2 = Credit memo item -->
                       <ReceivablesPropertyMovementDirectionCode>2</ReceivablesPropertyMovementDirectionCode>
                          <!-- <Description languageCode="EN">My invoice item</Description> -->
                          <CashDiscountDeductibleIndicator>false</CashDiscountDeductibleIndicator>
                          <Product>
                              <InternalID>{{ServiceProductID2}}</InternalID>
                              <TypeCode>2</TypeCode>
                          </Product>
                          <Quantity unitCode="HUR">10</Quantity>
                          <QuantityTypeCode>TIME</QuantityTypeCode>
                          <PriceAndTax>
                              <!-- List Price -->
                              <PriceComponent>
                                  <!-- TypeCode: 8PR1 = Gross list price, 7PR1 = Net list price -->
                                  <TypeCode>8PR1</TypeCode>
                                  <Rate>
                                      <DecimalValue>120</DecimalValue>
                                      <CurrencyCode>USD</CurrencyCode>
                                      <BaseDecimalValue>10</BaseDecimalValue>
                                      <BaseMeasureUnitCode>HUR</BaseMeasureUnitCode>
                                  </Rate>
                              </PriceComponent>
                          </PriceAndTax>
                          <ObjectNodeSenderTechnicalID>ITM_1</ObjectNodeSenderTechnicalID>
                      </Item>
      <!-- Invoice item | free text -->
                      <Item>
                          <BaseBusinessTransactionDocumentItemID>20</BaseBusinessTransactionDocumentItemID>
                          <ReceivablesPropertyMovementDirectionCode>2</ReceivablesPropertyMovementDirectionCode>
                          <Description languageCode="EN">My free text invoice item</Description>
                          <CashDiscountDeductibleIndicator>false</CashDiscountDeductibleIndicator>
                          <Quantity unitCode="EA">1</Quantity>
                          <QuantityTypeCode>EA</QuantityTypeCode>
                          <PriceAndTax>
                              <!-- List Price -->
                              <PriceComponent>
                                  <TypeCode>8PR1</TypeCode>
                                  <Rate>
                                      <DecimalValue>100.00</DecimalValue>
                                      <CurrencyCode>USD</CurrencyCode>
                                  </Rate>
                              </PriceComponent>
                          </PriceAndTax>
                          <ProductTaxDetails>
                              <ProductTaxationCharacteristicsCode listID="US">500</ProductTaxationCharacteristicsCode>
                          </ProductTaxDetails>
                          <AccountingCodingBlockAssignment>
                              <AccountingCodingBlock>
                                  <AccountingCodingBlockTypeCode>ACC</AccountingCodingBlockTypeCode>
                                  <GeneralLedgerAccountAliasCode>A-1700</GeneralLedgerAccountAliasCode>
                              </AccountingCodingBlock>
                          </AccountingCodingBlockAssignment>
                          <ObjectNodeSenderTechnicalID>ITM_2</ObjectNodeSenderTechnicalID>
                      </Item>
                  </CustomerInvoiceRequest>
              </glob:CustomerInvoiceRequestBundleMaintainRequest_sync>
          </soapenv:Body>
      </soapenv:Envelope>

      Best regards,
      Knut

       

      • Hi Knut,

        Sorry I didn’t thank you for this at the time – for some reason I didn’t get notified that you’d left a response, and I had moved onto something else. I am now back on this piece of work – thank you for the explanation; the gap in the ODATA PSM is still there today.

        I have a problem using the SOAP API though. Unless Sales Orders are scoped in, which in my customer’s tenant it is not, the SOAP API cannot create a Customer Invoice Request. You get a very cryptic error:

        No scheme configuration found for scheme ‘&CIRHP&’

        On another tenant with Sales Orders scoped in, I can create the customer invoice requests no problem. However scoping Sales Orders in is not an option on the tenant I need to do this on. Any advice?

        Greg

        • Hi Greg,

          I don’t think the error message is caused by the Sales Order scoping. Could you please log an incident in ByD to follow up on your issue?

          Thanks and best regards,
          Knut

          • Hi Knut,

            You are correct. After followup, it’s emerged that the option “Upload of Invoice Requests” needs to be in scope. Otherwise you get that very unhelpful error! Thanks again for the help.

            Greg

          • Hello Greg,

            May I know what did you do to post the direct Customer Invoice Request via SOAPUI? Can you share you xml code for request in

            CustomerInvoiceRequestBundleMaintainRequest_sync

            Thanks,

            Chester

             

  • Hi Knut

    I tested your end-to-end scenario field service and repair.
    We also need to read and update the field “Incident Description” in our scenario.
    Can you give me a hint how to update the field?

    Thank you and best regards
    Jasmin

    /
    • Hi Jasmin,

      please do the following:

      1. Add the node Root/TextCollection/Text to the service order OData service. As result you get a collection “ServiceOrderText” (I renamed it to “Text”) in the OData service.
      2. Now you can create, update and read the incident description using this collection. The text referring to the incident description has TypeCode “10006”.

      Text TypeCodes:

      • Incident description: 10006
      • Customer Information: 10024
      • Internal Comment: 10011

      Best regards,
      Knut

      • This example creates a service order incident description:

        POST /sap/byd/odata/cust/v1/tmserviceorder/TextCollection HTTP/1.1
        Host: …
        Content-Type: application/json
        x-csrf-token: …
        Accept: application/json
        cache-control: no-cache
        Postman-Token: …

        {
        “ParentObjectID”: “{{ServiceOrderObjectID}}”,
        “Text”: “Some incident description …”,
        “TypeCode”: “10006”
        }

        I’ll add this example to the next version of the OData samples on Github as well 🙂

         

  • Update: Today I uploaded a new version of API sample packages to the GitHub repository:

    • I restructured the repository to simplify installation and configuration.
    • Refactored and new sample OData services for master data incl. organisational structures, employees, business partners, customer, suppliers, employees, positions, materials and service products
    • Enhanced sample OData services for sales order, customer invoice request, customer invoices, …
    • New examples to order services and procure services
    • New examples to sell products from stock with external payment
    • New examples to process customer returns
    • New examples to pre-confirm payments using clearing house statements
    • New examples to confirm payments and clear open items using bank statements
    • New examples to create and process invoices with external payment
    • New examples to create sales orders with external prices, discounts and surcharges
    • New examples to access the payment monitor
    • Correction of supplier invoice examples to post invoices
    • Hi Knut

       

      we are currently implementing incoming Bank Statements with Odata. We have ran into a problem as we cannot get full data for BankStatement items using Odata compared to what can be seen in the CAS using Repository Explorer. It seems that item details are not as well in place as we need. Could you please advise?

      Olli

        • Hi Knut,

           

          it seems that SAP development team is not able to open required BO object:

          “We have analyzed the issue and discussed the issue with our Development team and due to technical reasons we cannot write enabled the BO”.
          This is quite an issue here as electronical banking is business as usual in nordic countries. Could we maybe have a sit down regarding this issue?
          Olli
  • Hi Knut,

    The EDM Type for the standard created on field is string instead of Datetime so we are not able to use all IntervalBoundaryTypeCode (ge, le etc..) for filter option.

    We have a requirement to filter the Odata query based on the creation datetime. Is there a way to achieve this.

     

    Thanks,

    Naveen

    • Hi Naveen,

      You find some examples to filter by the creation datetime in the Github repository. However, in my examples the edm type is always DateTime or DateTimeOffset. Which API type and entity are you looking for?

      Best regards,
      Knut

  • Hi Knut,

     

    We are currently implementing mass data upload with ODATA.

     

    We create Custom BO and Custom Odata Service.

     

    We have tens of thousands data to be uploaded, so, we’re testing with reference to Create 2 sales orders + get (batch) scenario.

    But it doesn’t work.

    POST : https://xxxxxxx.sapbydesign.com/sap/byd/odata/cust/v1/svinterface/$batch

    in the BODY,

    –batch_1
    Content-Type: multipart/mixed; boundary=changeset_2

    –changeset_2
    Content-Type: application/http
    Content-Transfer-Encoding: binary

    POST SvInterfaceCollection HTTP/1.1
    Content-Type: application/json
    Content-ID: 1
    Content-Length: 10000
    Accept: application/json

    {
    “SourceSystemDocumentID” : “Test097”,
    “IFResult” : “FAIL”,
    “SvInterfaceTransactionHead” :
    [
    {
    “Type1” : “10”,
    “Type2” : “ORD001”
    }
    {
    “Type1” : “10”,
    “Type2” : “ORD002”
    }
    ]
    }

    There is no response from system. there is ‘202 Accepted’ message only.

    Could you please advice?

     

    Best regards,

    J Choi

    /
  • Hi Knut,

    We are testing ways to interface with our SAP ByDesign system and currently we are thankfully using your sapbydesign-api-samples on Github.

    I try to update some Project Task Expenses using your Custom Odata Service, but I cannot find a way to make the change in the correct Period Plan.

    Can you guide me how I can add these Period Plans data to the Custom Odata Service?

    Thanks in advance

    Ronald van Herk

    • Hi Ronald,

      to add period plans you need to add the business object node Project/Task/TaskExpense/TaskExpensePeriodPlan to your OData service.

      Please note the following:

      • Mandatory elements are PlannedCostAmount and PlannedPeriod.
      • Make sure you added task plan data (e.g. planned expenses) before adding period plans because otherwise the period plans cannot be propagated and aggregated to upper levels correctly.
        Take into account that you have to schedule the task as well.
      • The sum (total amount) of all task expense period plan items needs to match the task expense amount. If this is not the case, then the system creates an additional period plan item with the remaining amount (this item is marked by the element Indicator – so I would suggest to add this element to the OData service as well).
      • The Description of period plans is not mandatory, but might be important from a business semantics point of view.

      Don’t mixup the TaskExpensePeriodPlan with the TaskExpense/PlannedPeriod. In ByD you can plan on multiple levels: task, work/material/expenses/revenues and on periods. The TaskExpense/PlannedPeriod refers to the timeframe for which a task expense item is planned in case you plan on that level.

      Sometimes you may observe, that you add a node to an OData service and some elements of this node are greyed out. In this case, save and activate your OData service, close it, reopen it, and now you can add the previously greyed out field (this is a known issue – we are working on it).

      Best regards,
      Knut

      • Hi Knut,

        Thank you for your quick response. I had to wait a few days before I could try because there was an issue in the latest release with uploading Custom Odata Service XML files.

        Now that works again, but the 2 mandatory fields PlannedCostAmount and PlannedPeriod.remain greyed out, even when I follow your instructions to save and activate and then close and re-open the service. Could it be that that is also an issue with the latest release?

        I am a little stuck now, I hope you have maybe an idea? Could you add them to your khproject.xml on github for example?

        Warm regards,

        Ronald

        • Hi Knut,

          I managed to select the 2 mandatory fields now, I think I overlooked something on my end.

          Maybe a more general question: How can I know that there are mandatory elements when constructing a Custom Odata service? Can we find that in the SAP documentation?

          Warm regards,

          Ronald

           

  • Hi Knut,

    thanks for this comprehensive summary when working with SAP ByD’s API.

    I want to add a BusinessPartner (Company) to our system via API and therefore tried uploading your OData Services (khbusinesspartner.xml) from Githhub. Unfortunately this fails. Is it possible that with SAP 2005 the xml structure of OData Services changed?

    I also haven’t been able to shift an ODataServices in May from our Testtenant (already ByD 2005) to our Productivetenant (still ByD 2002).

    If the xml structure has changed: Is there a possibility to merge your Services from Github to the new structure? Or can you download them once again and share with us?

    Thanks & Regards

    Adrian

  • Hi Knut,

    We are using SAP ByDesign OData to integrate with K2 software.

    K2 will create a service instance from the metadata of OData but not work with

    OData API for Reports because metadata of Key ID missing Nullable attribute.

    This is the Error message from K2 software.

    Could you have any idea? Or Is it possible we can fix metadata of OData API for Reports?

     

    Thanks & Regards

    Warut