Skip to Content

How to get the live data Model Variable Value?

Hello Experts,

I created a CDS View type with parameter and exposed that CDS view to SAP Analytics cloud using live data Model.

When I Access this model a prompt dialog will ask me to input value to that Parameter given in CDS view like below screenshot. SAC will store this value as variable.I am able to get the Variable id, description as show below . But i am not able to get the value of that parameter.

Can any one help me out this problem.

Thanks & Regards

Lathasri

variable.png (23.6 kB)
script.png (13.8 kB)
Add a comment
10|10000 characters needed characters exceeded

  • Hi,

    I just did this with a model input parameter.

    In HANA, I created an Input Parameter:

    Name: IP_SELECTED_ITEM_1
    Type: NVARCHAR(50)
    Parameter Type: Direct

    In HANA, I also created a calculated column:

    Name: ITEM_A
    Type: NVARCHAR(50)
    Expression: '$$IP_SELECTED_ITEM_1$$'

    Screenshot of Semantics node:

    In SAC, the model column is visible in the SAC model:

    Then, I add a table with the dimension ITEM_A, and what ever measure I want.
    Name of the table: tblStatistics

    Then I use this code to get the value:

    var dsSI = tblStatistics.getDataSource();
    var rsSelected = dsSI.getResultSet();
    var Item_A = rsSelected[0]["ITEM_A"].id;

    This works perfect for me, and I also use it to determine when the data source has actually refreshed.

    comment.png (4.5 kB)
    comment.png (9.3 kB)

Related questions

3 Answers

  • Posted on Feb 14, 2020 at 10:36 PM

    Hi Lathasri,

    (I put an answer in the blog comment, and I am repeating here, so that we can have a discussion)

    Blog: Retrieving Selections from a Chart (Analytics Designer)

    In HANA

    If the parameter is assigned to a calculated column, then it would appear on every row of data. If you wanted it to remain constant, then the calculated column would simply be equal to the parameter. If you wanted it to vary by row, then you could include other columns in the calculation.

    In SAC

    In SAC include the data source in a table or chart. Once in a table or chart, you could then get the value using the techniques discussed in blogs: (Retrieving Selections from a Chart (Analytics Designer) or (Retrieving Selected Measure Values from a Chart).

    You can isolate just the data you want by passing a parameter filter to return just the rows that you need to retrieve the parameter value.

    Please reply with your comments and we can dive deeper into this if nescessary.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Robert,

      Thank you for your answer and actually my requirement is i am sending the parameter is date variable so i should n't add that to calculated column and i am retrieving the data based on my date that's completed i would like to access/see my date in analytical application from the datasource.

      Thank you & Regards

      Lathasri

  • Posted on Feb 15, 2020 at 05:02 PM

    Hi Lathasri,

    I just need clarification on this part:

    ...i am sending the parameter is date variable...

    Does this mean that someone is answering a prompt when the application starts up? And, then you are not able to capture it, because they are entering it into a system dialog?

    If this is the case, then maybe you can place a dropdown or table list of dates, or even an input field to type a date. Then, after the date is defined pass it to the data source using code like this:

    x.getDataSource().setVariableValue("IP_DATE", inpDate.getValue());

    In this manner, you would not have to retrieve the date, because you captured it in one of your canvas widgets.

    If this is not good, then please explain a little better, and I will create an outline of a solution for you. If it is correct and you need a little more information, then I will outline this solution.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 24, 2020 at 10:45 AM

    we can use this to get the variable value

    ConditionRecordsTable.getDataSource().getVariableValues();

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.