Basic scripting differences in SAC Analytical application designer Vs Lumira
Common scripting difference between Lumira Designer and SAC analytical application designer– Basic level
This blog post is for beginner level SAC analytical application developers who have worked on Lumira designer. As a first step, only a few scripting features are discussed over here comparing them with Lumira scripting. I will be preparing more advanced features in upcoming posts. This will be helpful for developers who want to do some hands-on using SAC analytical application designer. Please note the examples here are created using sample models provided in SAC.
Lumira designer does not have switch functionality. Hence, we had to write multiple ‘if else’ statements when we need to perform different functionality for different values of a variable
In SAC analytical application designer, we have switch statement which helps to implement logic quite less cumbersome way.
Consider an application created on sample model – BestRunJuice. I have a table and a radio button to change the dimension that is being displayed as below. On select of Store, product gets removed and store gets added
I am using switch to identify each selection and deciding on the action to be performed as below
Above code is simple with no if else statements
Double and triple equals
In Lumira, we only have double equal operator. But in SAC we have both double and triple equal operators. Double equals have automatic type cast whereas triple equals will not. To be more precise, double equals casts the operand to target type and condition gets satisfied. Hence at times, its ambiguous.
Consider analytical application with a donut chart and a dropdown on top to dynamically select the measure that is being plotted on.
Here I need to display a text based on the selected measure. If we use double equal, we will be getting below warning
Instead, we can use as below
applyText function instead of setText function
For texts, we use setText function in Lumira designer to assign text during runtime. But in SAC it’s replaced by applyText as in above example
Data sources are not independent in SAC
In Lumira, we can access data sources of each widget independently by referring their name. If the data source of a chart is DS_1 and we have to apply filter on it on a particular dimension, it can be done in script by just DS_1.setFilerExt( “COUNTRY”, ‘AUS’).
In SAC, we need to get the data source assigned to a widget by using below syntax
var ds1 = Table_1.getDataSource( );
then we need to apply required filter as below
Alert() feature is replaced using console.log() function
As developers, we used to use alert functionality in Lumira Designer for debugging variable values during runtime in Local mode. Here in SAC, we have Console.log functionality with which we can print values in console, which can be accessed through developer tools (F12) from browser
In the below example, we can change the measure that is shown in donut chart using dropdown. On selecting a particular value that is printed using below code
var selected = this.getSelectedKey();
console.log(“Selected measure – “+selected);
These examples will be useful while writing scripts in SAC analytical application designer. This would be useful in multiple places where you want to use switch, dropdowns, console to print variable values while debugging, data source references in an application and conditional operators.
Please share your valuable feedback in comments and follow my profile if interested on new blogs from me
You can follow community pages for more insights
- https://community.sap.com/topics/cloud-analytics – To follow the topic page for SAP Cloud Analytics
- https://answers.sap.com/tags/67838200100800006884 – For posting your queries and answers to other developer’s questions
- https://blogs.sap.com/tags/67838200100800006884/ – All SAP analytic cloud blogs are available here
- Reference : https://blogs.sap.com/2022/06/14/analytics-designer-developer-handbook-update-version-12.1/
This is indeed a helpful comparison Sivakami and thank you for sharing.
Especially the “data source is not independent in SAC” causes performance issues in some cases as each widget has to be filtered independently