2026 Jan 21 10:27 AM - edited 2026 Jan 21 10:31 AM
Hello all,
in SAC I use BW live connection within a story. To read the value of a variable 0S_CUS I use:
var cust = Chart_59.getDataSource().getVariableValues("0S_CUS")[0];Then I try to compare the value of variable "cust". Why: I would like to hide some pages in my SAC story if the customer number is greater than 10000000. The infoobject for variable 0S_CUS is 0CUSTOMER (data type: CHAR, length 10).
But this is not working:
var border = "0010000000";
if (cust > border) {
Application.setPageVisible("Page_7", false);
} else {
Application.setPageVisible("Page_7", true);
}
The variable 0S_CUS is a select-option but we pre-fill it with only one value.
The error is: auto-type conversion isn't supported.
Thanks for your help!
Request clarification before answering.
You can try the below to get the value of variable.
var cust = Chart_59.getDataSource().getVariableValues("0S_CUS")[0];
if (cust.type==VariableValueType.Single)
{
var singleValue = cast(Type.SingleVariableValue, value);
var cust_val=singleValue.value;
}
cust_val could be directly an integer and if not you can convert to integer as below.
cust_num=ConvertUtils.stringToNumber(cust_val);
Hope this helps !
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nikhil,
The following script works for me:
var cust = Chart_59.getDataSource().getVariableValues("0S_CUS")[0];
var cust_single = cast(Type.SingleVariableValue, cust);
var cust_val = cust_single.value;
var cust_num = ConvertUtils.stringToNumber(cust_val);
var border = 10000000;
if (cust_num > border) {
Application.setPageVisible("Page_7", false);
} else {
Application.setPageVisible("Page_7", true);
}
Thanks for your help!
Regards,
Yvonne
Yj,
var border = "0010000000"; This variable is of type string and you are trying to do an integer operation > on it which would not work.
Please convert both both cust and border explicitly to number/integer and then try the comparison. You can use the below
ConvertUtils.stringToNumber(stringVariable)
border_num=ConvertUtils.stringToNumber(border);
cust_num=ConvertUtils.stringToNumber(cust);
if (cust_num > border_num) {
Application.setPageVisible("Page_7", false);
} else {
Application.setPageVisible("Page_7", true);
}
Hope this helps !
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nikhil,
Thank you. I try the following:
var cust = Chart_59.getDataSource().getVariableValues("0S_CUS")[0];
var cust_num = ConvertUtils.stringToNumber(cust);
But for the conversion from STRING to NUMBER, I get the error message: Invalid argument at index 1: Cannot convert from "VariableValue" to "string"
Regards,
Yvonne
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 7 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.