Quite often, client requirements call for multiple functionalities within the same dashboard. Some of these requirements include:

  • Setting up a default view and default set of filters on a dashboard for a client
  • Populating members of a dropdown box, or adding members to an existing dropdown
  • Setting a default list of a selected members in a multi-select list box
  • Splitting up of a delimited string to display elements separately
SAP seems to have hit the nail right on the head with the introduction of new features in SAP Design Studio 1.3 to address these requirements. While all of these features are now available for easier and direct manipulation by developers, they do have one common denominator – the use of Arrays. One could go so far as to say that the core that was developed to stabilize all of these new features are Arrays.
While using features and methods to manipulate bookmarks, dropdowns and concatenated strings is easy enough, they are made that much easier with a thorough understanding of Arrays and their features. To that end, we have come with a document that can explain the A to Z of Arrays.

 

Different types of Arrays in SAP Design Studio 1.3

Different types of Arrays in Design Studio 1.3

There are 7 different types of arrays available – subtypes of the object “Array”. These include:

Dimension Array:
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.
Dimension Array in SAP Design Studio 1.3
Hierarchy Array:
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.
Hierarchy Array in SAP Design Studio 1.3
Member Array:
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.
Member Array in SAP Design Studio 1.3
Bookmark Array:
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.
Bookmark Array in SAP Design Studio 1.3
Variable Array:
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.
Variable Array in SAP Design Studio 1.3
String Array:
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:
String Array in SAP Design Studio 1.3
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.

Integer Array:
This subtype can contain a list of integers. This type of an array can also be created manually by users.
Integer Array in SAP Design Studio 1.3
Float Array:
This subtype can contain a list of decimal point numbers or floats. This type of an array can also be created manually by users.
Float Array in SAP Design Studio 1.3
Manipulating elements of an Array:
Individual elements of an array can be accessed using the “forEach” loop. The basic syntax for this :
Manipulating elements of an array in SAP Design Studio
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:

  • “element” refers to the individual elements contained in the array, one at a time.
  • “index” refers to the index/position of that particular element within the array.

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:

It should be noted that the “element” object does not have any methods for an Integer or a Float Array)

Examples of Arrays in use:
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.
Sample use of String Array in SAP Design Styudio 1.3
The result of this program is an alert window shown below.
Alert Window
Dimension Arrays in Use:
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:
Sample use of Dimension Array in SAP Design Styudio 1.3
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+”);”;});
APPLICATION.alert(“Dimensions in Row:n”+Rows+”nnDimensions in Cols:n”+Cols+”nnDimensions in Free Characteristics:n”+Free+”nnOverall:n”+Overall);

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:
Alert Window
Hierarchy Arrays in Use:
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:
Sample use of Hierarchy Array in SAP Design Studio 1.3
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+”);”;});
APPLICATION.alert(“Hierarchies Available:n”+Hierarchy);

The output, if hierarchies are available on the given dimension (which is the case here), should resemble the screenshot shown below:
Alert Window

You can also download the pdf version of “Arrays in SAP Design Studio 1.3” here:

Learn more

Subscribe to our Newsletter

5920 Windhaven Pkwy
Plano TX 75093.

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192

solutions@visualbi.com