Skip to Content
Technical Articles
Author's profile photo Knut Heusermann

OData Example: Get supplier data by tax numbers

Using the SAP Business ByDesign OData API for business objects you can easily query and get supplier data by its tax identification number (for example the VAT number).

Here are 4 ways to find a supplier by its tax ID:

Preparation: Expose SAP ByDesign supplier tax data via OData

Open work center view Application and User Management – OData Services and create a Custom OData Service for business object Supplier and include the following business object nodes and elements:

Please note, that I selected the “Enable Search“-indicator for the elements InternalID, BusinessPartnerFormattedName and PartyTaxID such that I can use the OData parameter $search to find suppliers using these elements.

Under Function Imports I added the query QueryByBusinessObjectSupplier:

Save and activate the Custom OData Service.

 

Option 1: Query

Using the query function import you can get the supplier by its tax ID.

Sample OData request:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsupplier/QuerySupplier?NumberOfRows=’20’&PartyTaxID=’SE999999999901’&TaxCountryCode=’SE’&TaxIdentificationNumberTypeCode=’1′

As result you get the supplier root data incl. information such as the UUID, the InternalID and the supplier name.

 

Option 2: Filter

By a GET request on the business object node SupplierTaxNumber you can get supplier tax data using the tax ID as filter parameter. Using the OData parameter $expand you can follow the assoziation to the supplier root node and include the supplier internal ID, supplier UUID and the supplier name into the OData response.

Sample OData request:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsupplier/SupplierTaxNumberCollection?$format=json&$expand=Supplier&$filter=CountryCode eq ‘SE’ and PartyTaxID eq ‘SE999999999901’

 

Option 3: Search

Similar to option 2 you can use the OData parameter $search to get the supplier tax data by the tax ID and incl. the supplier root node into the response.

Sample OData request:

https://{{TenantHostname}}/sap/byd/odata/cust/v1/khsupplier/SupplierTaxNumberCollection?$format=json&$expand=Supplier&$search=SE999999999901

 

Option 4: OData API for Data Sources

If you want to get the supplier from its tax ID using a technical user, then you could use the OData API for data sources.

Preparations:

  1. Activate the OData API for analytical data sources in your Business Configuration Scope.
  2. Create a Communication System that represents the remote system. Create a Communication Arrangement for the communication scenarios “Analytics DataSources OData”.
  3. Externally expose the data sources Supplier Details (BPSPPB) and Supplier Master Data (SUPPLIER).

Get the supplier UUID by the supplier tax ID, for example:

https://{{TenantHostname}}/sap/byd/odata/analytics/ds/Bpsppb.svc/Bpsppb?$select=C_BpUuid,C_TaxCountry,C_TaxType,C_TaxIdNr,Count&$format=json&$filter=C_TaxCountry eq ‘SE’ and C_TaxIdNr eq ‘SE999999999901’

and then follow the assoziation “to_BpUuid” or get the supplier master data by the supplier UUID, for example:

https://{{TenantHostname}}/sap/byd/odata/analytics/ds/Bpsppb.svc/Supplier?$select=C_BpUuid,C_BpIntId,T_BpFrmtdName,Count&$format=json&$filter=C_BpUuid eq guid’00000000-0001-1DEF-BA9F-CD59144F3576′

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Hanumath Kanamarlapudi
      Hanumath Kanamarlapudi

      Knut,

      This blog is excellent.

      I have a different need of reading the data using the ODATA API's but those ODATA API's are on any standard/custom reports of ByDesign.

      In this case how can I do this?

      I have tried using the standard library listed under "Platinum Engineering" namespace and I dont see anything turned to be positive and the script file is not activating further to execute the ODATA report

      Please look into the below question on the same

      https://answers.sap.com/questions/12662151/how-to-use-the-odatareportexecute-method-from-the.html

      Thanks

      Hanu K