Spend Management Blogs by SAP
Stay current on SAP Ariba for direct and indirect spend, SAP Fieldglass for workforce management, and SAP Concur for travel and expense with blog posts by SAP.
cancel
Showing results for 
Search instead for 
Did you mean: 
ajmaradiaga
Developer Advocate
Developer Advocate
2,130
In this blog post I share how to update the fields and filter of a custom view template in the SAP Ariba Analytical Reporting API.

In the documentation of the SAP Ariba Analytical Reporting API, an example of how to update the status of a custom view template is given. There is no example of how the select and filter fields can also be updated by using the patch method (https://openapi.ariba.com/api/analytics-reporting-view/v1/prod/viewTemplates/{MyCustomViewTemplate}/...) available in the API.

When do you need to update a custom view template?


This will be especially useful when you are developing a reporting application and are unsure of which fields to extract or which filters are required.
It is not possible to modify the system views available (view templates ending in "SystemView"). If you want to "modify" one, just extract the metadata of the system view and use this to create a custom view template.

Creating a view template -> ScorecardFactCustom


Let's first create a custom view template. In the example below I will use the ScorecardFact document type, with no filters and only a subset of fields.

 
curl --location --request POST 'https://openapi.ariba.com/api/analytics-reporting-view/v1/prod/viewTemplates/ScorecardFactCustom?realm=myrealm-T' \
--header 'Content-Type: application/json' \
--header 'apikey: [MY_API_KEY]' \
--header 'Authorization: Bearer eb04b750-1234-5678-9012-0dca7bdaba2a' \
--data-raw '{
"documentType": "ScorecardFact",
"status": "published",
"selectAttributes": [
"LoadCreateTime",
"LoadUpdateTime",
"Scorecard",
"SourceSystem",
"Status",
"PeriodFrom",
"PeriodTo",
"Project",
"Supplier",
"Owner",
"Value",
"Weight",
"Target",
"Grade",
"SystemGrade",
"TimeCreated",
"TimeUpdated"
],
"filterExpressions": []
}'

Updating a view template


Now let's update the previously created custom view template by adding more fields and specifying some filters.

 
curl --location --request POST 'https://openapi.ariba.com/api/analytics-reporting-view/v1/prod/viewTemplates/ScorecardFactCustom/patch?realm=myrealm-T' \
--header 'Content-Type: application/json' \
--header 'apikey: [MY_API_KEY]' \
--header 'Authorization: Bearer eb04b750-1234-5678-9012-0dca7bdaba2a' \
--data-raw '{
"status": "published",
"selectAttributes": [
"LoadCreateTime",
"LoadUpdateTime",
"Scorecard",
"SourceSystem",
"Status",
"PeriodFrom",
"PeriodTo",
"Project",
"Supplier",
"Owner",
"Commodity.Commodity",
"Department.Department",
"GradeCount",
"Value",
"Weight",
"Target",
"Grade",
"SystemGrade",
"RespondentUser",
"RespondentDepartment",
"RespGradeCount",
"RespondentGrade",
"TimeCreated",
"TimeUpdated"
],
"filterExpressions": [
{
"name": "WeightValue",
"field": "Weight",
"op": "=",
"defaultValue": 100.0
},
{
"name": "updatedDateTo",
"field": "TimeUpdated",
"op": "<=",
"defaultValue": null
},
{
"name": "updatedDateFrom",
"field": "TimeUpdated",
"op": ">",
"defaultValue": null
}
]
}'

If you now retrieve the metadata of the custom view template (command below), you will see the newly added fields and filters.
curl --location --request GET 'https://openapi.ariba.com/api/analytics-reporting-view/v1/prod/viewTemplates/ScorecardFactCustom?realm=myrealm-T' \
--header 'apikey: [MY_API_KEY]' \
--header 'Authorization: Bearer eb04b750-1234-5678-9012-0dca7bdaba2a'

I hope this little tip helps you when defining your custom view templates and speeds up your development process.
2 Comments