SAC Scripting – Part 2: Shadow Tables

1.    General

In this detailed exploration, we contrast the efficiency of accessing dimension values through Input Control and a shadow table in scripting environments. We previously introduced array manipulation and now extend our focus to performance aspects of data retrieval. The shadow table, designed as a dedicated storage for dimension values, allows for hidden storage when inactive, potentially improving access speeds especially when these dimensions are also part of a reporting chart.

For those inclined to access Input Control values via InputControl.getInputControlDataSource().getActiveSelectedMembers(), it’s worth noting that SAP Analytics Cloud (SAC) triggers backend metadata retrieval and an additional query call. This supplementary query call can significantly impact performance in certain scenarios.

2.    Scenario

In this scenario, we’ll examine the values within the location dimension of the data source. The „Fill array from Dropdown“ Button will retrieve values from the Location InputControl, whereas the „Fill array from Table“ Button will access values from the table, which might be visible or hidden in a real-life scenario. To ensure a fair comparison, we’ll include the loading time of the table in the performance evaluation of the shadow table. Additionally, we’ll conduct a second comparison when a filter for the Product InputControl is applied.

3.    Comparison 

The two buttons having scripts to monitor the performance of data access. For the Shadow table Button, we must monitor both the loading time of the table (stored in the variable svar_tableloadingtime) and the access on the result set.

3.1   Button ( Dropdown Fill from Array )

/* Returns the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC. */

var var_before = Date.now();

 

/* Get selected values from dropdown */

var test = InputControl_Location.getInputControlDataSource().getActiveSelectedMembers();

 

var var_after = Date.now();

 

var diff = var_after - var_before;

 

var text = "Elapsed Time in ms: " + ConvertUtils.numberToString(diff) + " \n" + " \n";

 

for (var i = 0; i < test.length; i++){

 

    text = text + test[i].description + " \n";      

 

}

 

Text_Execution.applyText(text);

3.2   Button ( Dropdown Fill from table )

var var_before = Date.now(); 

 

// Get location values from Table 

var location =  Table_BestRun.getDataSource().getResultSet(); 

 

var var_after = Date.now(); 

var diff = var_after - var_before; 

 

var total = diff + svar_tableloadingtime; 

 

var text = "Elapsed Time in ms: " + ConvertUtils.numberToString(total) + " \n" + "Elapsed Time table load ms: " + ConvertUtils.numberToString(svar_tableloadingtime) + " \n" + "Elapsed Time getResultset ms: " + ConvertUtils.numberToString(diff) + " \n" + " \n"; 

 

for (var i=0;i<location.length;i++) {    

    svar_string_A_location.push(location[i]["Location_4nm2e04531"].id); 

    text = text + location[i]["Location_4nm2e04531"].description + " \n";        

    } 

 

Text_Execution.applyText(text); 

4.    Overview

Within the After Initialization scenario for the Dropdown Access we have an additional metadata call which is requested from the backend and takes 50% ( 1500 ms ) of the total time. So generally, I would recommend using the Shadow table access which in general is having a better performance compared to the Input Control.

5.    Final Thoughts

Today, we caught a glimpse of how performance-related topics can be addressed within the unified story. In the next chapter, we’ll explore methods for enhancing performance in larger scenarios.

Related Blogs