Technical Articles
Using the SAP Ariba APIs to extract inactive suppliers
In this blog post, we will cover how we can use the SAP Ariba APIs to programmatically extract inactive suppliers from a realm. To achieve this, we will use the Operational Reporting API for Strategic Sourcing.
Why might we want to retrieve the list of inactive suppliers programmatically?
Suppliers can be synced to 3rd party systems and once a supplier is inactive we might want to delete the data in these systems after a period of time. This can be for GDPR reasons for example.
We might want to create a report on the suppliers recently inactivated in SAP Ariba. Using the Operational Reporting API for Strategic Sourcing we can extract the data required and populate a dataset that will be consumed by a reporting tool.
In SAP Ariba, how do we view inactive suppliers?
Although it is possible, via the SAP Ariba user interface (Manage > SM Administration > Inactive Suppliers), to view the inactive suppliers in the realm. There is no simple mechanism to export the list of inactive suppliers. If we use the Supplier export mechanism (Manage > SM Administration > Data import or export > File type: Suppliers), the system will only export active suppliers.
Can we automate extracting inactive suppliers?
TLDR; Yes! we can extract inactive suppliers by using the Operational Reporting API for strategic sourcing. In this blog, I will cover how this can be accomplished.
As mentioned above, it is possible to extract inactive suppliers with dates by using the Operational reporting API for strategic sourcing. To achieve this, we will need to do the following:
- Request access to the Operational Reporting API for Strategic Sourcing
- Retrieve an access token using the API application details
- Create a view template for organisations
- Retrieve the results of the view template and process the response.
Step 1 – Request access to the Operational Reporting API for Strategic Sourcing
To request API access, we need to follow the steps covered in the SAP Ariba Developer portal documentation: https://help.sap.com/viewer/b61dd8c7e22c4fe489f191f66b4c48d6/cloud/en-US/496d221506e941a894237243ca9ddf2a.html
- Once the application is created:
- Note the Application key that is generated. This will need to be included in the API requests below.
- Ask your administrator to Request access to the Operational Reporting API for Strategic Sourcing
After the API access has been approved by SAP Ariba support, the Developer portal administrator will be able to generate the OAuth Secret and Base64 Encoded Client and secret required to securely communicate with the API.
Step 2 – Retrieving an access token using the API application details
Once we have the API application details, we send a request that includes the base64AuthString to the OAuth URL to retrieve an access token. The access token will be included in the API requests (header Authorization) below.
curl --location --request POST 'https://api-eu.ariba.com/v2/oauth/token' \
--header 'Authorization: Basic YOUR_BASE64AUTHSTRING' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=openapi_2lo'
Step 3 – Create a view template for organisations
Now that we have an access token, we can interact with the different methods available in the API. We will start by creating a view template, which is required before retrieving reporting data from the API.
Things to take in consideration:
- Create view template with “documentType”: “Organization”. Example of request below.
- We can retrieve only the Organisation attributes that we are interested in.
- Optional: It is possible to specify a date filter for the template and modify it when retrieving the data.
Sample request:
curl --location --request POST 'https://eu.openapi.ariba.com/api/sourcing-reporting-view/v1/prod/viewTemplates/InactiveSuppliers?realm=realm_name-T' \
--header 'Content-Type: application/json' \
--header 'apiKey: YOUR_API_KEY' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--data-raw '{
"documentType": "Organization",
"status": "published",
"selectAttributes": [
"SystemID",
"SMVendorID",
"Name",
"OrganizationID.Ids.Domain",
"Parent",
"TimeCreated",
"TimeUpdated",
"Active",
"Blocked",
"BlockingReason"
],
"filterExpressions": [
{
"name": "updatedDateFrom",
"field": "TimeUpdated",
"op": ">=",
"defaultValue": "2019-10-05T01:01:59Z"
},
{
"name": "updatedDateTo",
"field": "TimeUpdated",
"op": "<=",
"defaultValue": "2020-07-08T13:01:59Z"
}
]
}'
Step 4 – Retrieve the results of the view template
Now that the view template has been created, all we are missing is extracting the data that we’ve defined in the view template. We can modify the filter expressions specified before if needed.
Things to take in consideration:
- When retrieving the view data, we need to include the includeInactive query parameter in the request – https://help.sap.com/viewer/c4f46b9331834a0b970f834c20c9c73b/cloud/en-US/df42b1634c474bab96a4576edc37eda7.html.
- (Optional) it is possible to specify the filter dates in the request, e.g. https://openapi.ariba.com/api/sourcing-reporting-details/v1/prod/views/InactiveSuppliers?realm=[realm_name-T]&includeInactive=true&filters={%22updatedDateFrom%22:%222020-07-01T00:00:00Z%22,%22updatedDateTo%22:%222020-07-09T00:00:00Z%22}‘
Sample request:
curl --location --request GET 'https://openapi.ariba.com/api/sourcing-reporting-details/v1/prod/views/InactiveSuppliers?realm=[realm_name-T]&includeInactive=true&filters={%22updatedDateFrom%22:%222020-07-01T00:00:00Z%22,%22updatedDateTo%22:%222020-07-09T00:00:00Z%22}' \
--header 'Content-Type: application/json' \
--header 'apiKey: YOUR_API_KEY' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--data-raw ''
Sample Response:
As we can see, we have retrieve inactive suppliers using InactiveSupplier view template that we defined in Step 3. Note that the response will include active and inactive suppliers, so we will require some further data processing. The program responsible for retrieving the data will need to process the response, ignore the active supplier included in it and only process the suppliers where “Active”: false.
I am trying to do this as a proof of concept exercise on extracting Ariba data into BW/4Hana via CPI. However, is there any step by step blog on what to do in the CPI, especially the Ariba token steps?
Hi Jonathan Ma
In this blog post, https://blogs.sap.com/2020/10/18/replicate-sap-ariba-analytical-data-to-big-query-using-sap-cloud-platform-integration/, you can find the step by step on the SAP Cloud Platform components related to Ariba. Regarding the Ariba token.... you don't need to worry about it as SAP Cloud Integration handles it on your behalf. All you need to do is deploy the security material and reference the credential name in the HTTP request where you are calling the Ariba API.
Regards,
.A
Thanks, Antonio
I already saw the other blog you mentioned. However, would you mind sharing the screenshots on steps like "set ariba data filter", "Ariba API key", "get analytical reporting data" and "process ariba response"? Sorry but it is all new to me. Unfortunately, the Ariba API seems to be an awfully complicated process with the access token and stuffs.