Skip to Content
0

Setting a bex formula variable from Design Studio

Dec 23, 2017 at 09:18 AM

174

avatar image

Hello,

1) I'm trying to set BEx Query variables from my Design Studio application. The variables are formula variables - that is, they represent floating point values that are used in a formula within the query (a calculated key figure, if that makes any difference). I want the correct formula value to be calculated once I set the variables.

I've loaded the data source and then used DS.setVariableValueExt for both variables. I have to first convert the values from float for this to work, I'm using Convert.floatToString (although I've tried just adding "" as well).

I've tried using reloadData to force the query to refresh with the variable values, however I don't appear to get results either after reloadData or after the code.

I've tried several ways of using getData, even for specific member values, but I don't get a relevant result.

I've tried showing the query results in a crosstab which also doesn't seem to show the values for the formula - all it does is show "NOT EXIST".

I have full control of the query and the variables.

2) An additional requirement is to have the variable values available for a cmod calculation in a characteristic value variable.

Thanks for any help,

Shai

10 |10000 characters needed characters left characters exceeded

Shai,

It would be helpful if you posted the complete script you are using to set the variable values, as well as a screenshot of the BEx Query Formula Variable definitions.

Also, have you confirmed that you get the desired results when you simply execute the BEx Query in BEx Analyzer or BEx Web?

Regards,

Mustafa.

0

Hi Mustafa,

This is the variable definition:

This is the code in Design Studio:

DS_1.loadDataSource();

var x = Convert.floatToString(somefloat);

DS_1.setVariableValueExt("Z_***_INPUT_SM_FV",x);

DS_1.reloadData();

printing somefloat to an alert shows the correct value. Executing the query from Bex Web while providing correct values to the variables returns the correct results.

Thanks,

Shai

jvxrg.png (23.9 kB)
qwpyr.png (13.3 kB)
0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Mustafa Bensan Dec 23, 2017 at 01:34 PM
0

Hi Shai,

I have just tried a simple example of a BEx Formula Variable used in a Calculated Key Figure and it works as expected. My sample code looks like this:

var myValue = 1.2875;
var myVariableValue = Convert.floatToString(myValue);

DS_1.setVariableValueExt("ZVAR_PERCENTAGE_UPLIFT", myVariableValue);

And my BEx Formula Variable is defined as follows:

Regards,

Mustafa.


Show 2 Share
10 |10000 characters needed characters left characters exceeded

I have the exact same settings, which made me realize that this was some sort of issue with the formula.

The formula is a calculation based on two input formula variables and two replacement path variables, replacing from a characteristic attribute. The "Not Exist" output seems to occur when trying to include both a replacement path variable and an input variable in the same formula.

This seems to be inconsistent. during my experiments the full formula suddenly worked for some reason. My take from all this is to separate the variables into different formulas and then use the partial formulas for the final calculation.

Mustafa - Thank you very much for your help!

- Shai

0

Hi Shai,

Thanks for sharing your findings. I agree that in these complex situations, rather than spending time trying to debug the root cause, it is usually easier to just break it into simpler pieces which are then used in the final result, as you've suggested.

Regards,

Mustafa.

0