Skip to Content

Setting a bex formula variable from Design Studio

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

Add comment
10|10000 characters needed 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.

  • 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)
  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 23, 2017 at 01:34 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.