Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
RajuRam
Active Participant
0 Likes
394

Introduction

While working with BW Live stories in SAP Analytics Cloud Advanced Mode, I learned that scripting must be defensive, explicit, and user-driven.
In this blog, I share the first three scripting learnings that consistently worked in real projects.

All examples below are error-free and production-safe.

 

  1. Always Convert Text Input Values Explicitly

Learning

Text Input widgets always return strings.
Using them directly in calculations or BW variables leads to errors.

Explicit conversion is mandatory.

 

Working Script Example

// Read value from Text Input

var inputValue = InputField_1.getValue();

 

// Convert string to number safely

var numericValue = ConvertUtils.stringToNumber(inputValue);

Why this works

  • No implicit type conversion
  • No runtime errors
  • Fully supported in SAC

 

  1. Keep User Input Simple, Convert Units in Script

Learning

Business users prefer entering simple numbers, such as millions.
BW Live variables expect full numeric values.

The script must handle the conversion.

 

Working Script Example

// Convert million value to full amount and feed BW variable

Table_Main.getDataSource()

    .setVariableValue("VAR_COST_MIN", numericValue * 1000000);

Benefits

  • Clean user experience
  • Accurate BW filtering
  • No confusion for business users

 

  1. Refresh BW Live Data Only After Setting Variables

Learning

BW Live does not automatically refresh after variable updates.
Refreshing too early or multiple times causes inconsistent behavior.

Always refresh once, after all variables are set.

 

Working Script Example

// Refresh BW Live data after variable assignment

Table_Main.getDataSource().refreshData();

Best Practice

  • One refresh per Execute button
  • Never refresh inside loops

 

Conclusion – Part 1

These three learnings form the foundation of stable BW Live scripting:

  • Explicit conversion
  • User-friendly units
  • Controlled refresh

In Part 2, I will cover advanced but safe patterns for helper tables and dynamic filtering.