SAP Design Studio 1.4 has been very surprising in many interesting ways ever since its release. Through this post, I have tried to capture some aspects of APIs in the latest release.
1. Application Scripts
a) getUserAgent() – Provides browser-specific information such as browser type, version and so on. This is typically helpful to avoid inconsistent behaviour of applications across different browsers.
Here is how a string is retrieved when this function is called:
Here is an explanation of the above string:
b) searchDataSources() – This script helps retrieving the datasources’ present in the specified connection. When you pass the connection parameters and the search string, it returns an array of DataSourceDescriptors.
Use Case: Can be used to consume different queries in a dashboard with a single DataSource alias and reassign it to a query upon selection from a dropdown
c) getResourceString() – Retrieves the Resource string of the ID that is passed as a parameter.
2. State Scripts
To utilise the undo features on State Scripts, define the “Maximum number of Undo Steps” property in Application properties tab. Maximum number of steps is limited to 20.
a) backOneStep() – The state of the application is reverted by one step. This captures all the filters applied but cannot remove the selection made in the component.
b) backToStart() – Very helpful in restoring the application to its original state. It required manual code to do this earlier by clearing filters and hiding the components.
c) isBackOneStepAvailable() – Returns the availability or non-availability of a previous step.
d) isBackToStartAvailable() – Ensures whether the Reset Initial view option is available.
The following screen shows the initial view of a dashboard:
As a first step I have applied dimension filter to the chart on right.
In subsequent steps, a drilldown filter is applied from crosstab and yearly data chart.
While clicking the ‘Undo’ button, the dashboard state is gone one step backward. Keep a track of count near ‘Undo’ button.
On subsequent Undo, a message is prompted that says the initial view has been reached.
Similarly, we could use the script ‘backToStart()’ for the ‘Reset’ button, that restoring the dashboard to its initial state by clearing any filters that are applied to it.
Here are the code snippets for the above functions:
Caution: While using the undo/reset features, the few selection changes are not reverted but the processing happens in the background
3. Dimension Filter
a)setDimension()– Enables us to change the Dimension set to Dimension Filter dynamically at run time. So by having a single Dimension Filter we can filter across many dimensions by switching
Caution: After the dimension has been changed at runtime, the name of the changed Dimension cannot be fetched via getDimensionByName() API. This function returns the initial dimension but not the changed one.
b) showFilterDialog()– Displays the Dialog box of the Dimension Filter on demand.
Caution: The Dialog box is shown only on the page where the Dimension Filter Component exists and not on a different page.
The following APIs have been added in SAP Design Studio 1.4:
a) Conditional Formatting:
APIs are available to retrieve the Conditional Formats (Exceptions) that are applied at BEx and implement it in our Dashboard when required. Related APIs are as:
Use case: Created a query with three Exceptions later consuming it in SAP Design Studio Application. All the Exceptions are populated in a List Box and applying those on demand. A Text Box is populated to depict which particular Conditional Format is applied based on List Box selection.
b) Measure Filters:
Handful of new APIs with respect to “Measures” is as follows:
- getMeasuresDimension() – Retrieves only the Measures in the DataSource. It’s a subset of getDimensions() function where all the dimensions along with Measures(Key Figures) are retrieved.
Use case: Created a query with two conditions that is to be consumed in the Application. All the Conditions (Filters) are populated in a List Box and applied on-demand. A Text Box is populated to depict which particular Measure Filter is applied based on List Box selection. An Input Field is used to set value for the Filter.
This API was listed in the ‘What’s New Guide of SAP Design Studio 1.4′ as a recent addition, under the objectDataSource Alias but I was not able to locate in the SAP Design Studio 1.4 Application.
These are some features that I found interesting (in addition to what’s here) to me but the quest for more interesting features is still on.