With the release of Design Studio 1.3, a host of new features were brought in by SAP. One of the most useful is the concept of Arrays. Though the versatility of this feature is quite limited in this release, SAP has nevertheless offered certain aspects of Arrays that developers can play around with.
Considering the rather concise information available in the designer guide, it seemed useful to provide a detailed overview of this feature. So, here goes !
There are 7 different types of arrays available – subtypes of the object “Array”. These include:
This subtype can contain a list of different dimensions belonging to a data source. A dimension array can be created by referencing the “getDimensions()” method of a data source – dimensions belonging to rows, columns, free characteristics or all dimensions available in the data source can be obtained with this method.
This subtype can contain a list of hierarchies. While there is no way for a user to create a hierarchy array manually, it can be created using the “getHierarchies()” method of a data source. This returns a list of different hierarchies available for the dimension that has been passed as parameter to the method.
This subtype can contain a list of members belonging to a dimension. It can be created using the “getMembers()” method of a data Source. The method returns a list of members of a dimension as an array. The dimension for which the members are required must be passed as a parameter to the method.
This subtype can contain a list of all bookmarks for an application. Such a type of Array can be created using the “getAllBookmarks()” method of the “Bookmarks” object. When the method is used, it returns all the available bookmarks for that particular application.
This subtype can contain a list of variables. It can be created using the “getVariables()” method of a data source. This method returns all the available variables of the data source for which the method is being called.
This subtype can contain a list of strings. Unlike the previously mentioned types of arrays, a String array can be created manually as well. This is shown in the screenshot below:
Apart from user customizable string arrays, the “getSelectedValues()” and “getSelectedTexts()” methods of a Multi-Select enabled List Box can also return values in the form of a String Array. Using the “Split()” method will also return a String Array.
This subtype can contain a list of integers. This type of an array can also be created manually by users.
This subtype can contain a list of decimal point numbers or floats. This type of an array can also be created manually by users.
Individual elements of an array can be accessed using the “forEach” loop. The basic syntax for this :
The “forEach” loop iterates over each element of an array and executes the statements contained within the body of the loop. In the above syntax:
Each element object has its own set of methods to access attributes of that element, depending on the array type. For instance, when handling a MemberArray, the external keys and internal keys of the elements can be accessed through methods of the “element” object. A list of the different methods available for each type of array has been given below:
Array Type | Methods belonging to “element” object |
DimensionArray |
|
HierarchyArray |
|
MemberArray |
|
BookmarkArray |
|
VariableArray |
|
StringArray |
|
(It should be noted that the “element” object does not have any methods for an Integer or a Float Array)
The program below takes a String array, eliminates the word “WORLD” and returns the remaining elements of the StringArray as one concatenated string, in an application alert window.
The result of this program is an alert window shown below.
Given below is an example of dimension arrays in use. Consider the dimensions of the data source arranged in the manner shown in the screenshot below:
The script below exhibits the different ways in which the “getDimensions()” function can be used:
var Dim_Array_Rows = DS_1.getDimensions(Axis.ROWS);
var Dim_Array_Cols = DS_1.getDimensions(Axis.COLUMNS);
var Dim_Array_Free = DS_1.getDimensions(Axis.FREE);
var Dim_Array_All = DS_1.getDimensions();
var Rows = "";
var Cols = "";
var Free = "";
var Overall = "";
Dim_Array_Rows.forEach(function(element, index) {
Rows = Rows + element.name +" ("+element.text+");";
});
Dim_Array_Cols.forEach(function(element, index) {
Cols = Cols + element.name+" ("+element.text+");";
});
Dim_Array_Free.forEach(function(element, index) {
Free = Free + element.name+" ("+element.text+");";
});
Dim_Array_All.forEach(function(element, index) {
Overall = Overall + element.name+" ("+element.text+");";
});
The script shown in the above window consolidates a list of all the dimensions belonging to the data source, and displays them on an alert window as shown in the output below:
Given below is an example of hierarchy arrays in use. Observe the different hierarchies available for the dimension “ZREGION” in the structure of the query shown in the screenshot below:
The script below simulates a situation where in the hierarchies available in a particular dimension (“ZREGION” in this case) are obtained and displayed on an alert dialogue as soon as the user clicks a button present on the screen:
var Dim_Hierarchy = DS_1.getHierarchies("ZREGION");
var Hierarchy = "";
Dim_Hierarchy.forEach(function(element, index) {
Hierarchy = Hierarchy + element.name + " ("+element.text+");";
});
The output, if hierarchies are available on the given dimension (which is the case here), should resemble the screenshot shown below:
(Source: Learn about Arrays in Design Studio 1.3 - Visual BI)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
14 | |
10 | |
7 | |
7 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 |