8

Basic scripting differences in SAC Analytical application designer Vs Lumira

 2 years ago
source link: https://blogs.sap.com/2022/08/26/basic-scripting-differences-in-sac-analytical-application-designer-vs-lumira/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
August 26, 2022 3 minute read

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.

Switch

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.

Example:

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

Switch_1

Switch_1

I am using switch to identify each selection and deciding on the action to be performed as below

Switch_2

Switch_2

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.

Example:

Consider analytical application with a donut chart and a dropdown on top to dynamically select the measure that is being plotted on.

Pic6.png

Here I need to display a text based on the selected measure. If we use double equal, we will be getting below warning

double_eq

double_eq

Instead, we can use as below

Pic4.png

applyText

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

ds1.setDimensionFilter(“COUNTRY”, “AUS”)

Log function

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);

Chart_1.addMeasure(selected,Feed.Size);

Developer tools

Console

Console

Conclusion

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK