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/496d221506e941a894237243ca9...
- Log in to the developer portal.
- Create application from the home page.
- Fill out the Create a new application form and hit Submit.
- 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:
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.