Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Karol-K
Advisor
Advisor

One more idea - this time the old topic of what-if-analysis in design studio. It show another open direction with data iterator and byo data source. The goal is to have simple data manipulation and what-if-analysis with the changed data.


Mike has already described the option of adding data rows to BYO data source in his initial blog: Design Studio SDK (1.4) - Bring Your Own (BYO) Datasource.

Now, having the data iterator which allows mixing 2 data sources from any source system - blog here - Design Studio 1.6 - Data Blending with Data Iterator & Bring Your Own Data Source, it is even possible to bind those two options.


I have build-up the example from the data blending blog into more advanced option and combination of slider, input component and UI5 table with selection model to adjust existing data.


The Working example look like this (animated GIF, click to expand)


What is In?


First,

the simplest case - you can add new rows to the data source (as described by Mike) and then the full blending code from my blog executes again - so you can calculate revenue for the new entry and get it in all other components bound to the result data source.


Script:

DS_SALES.addRow("Apples,University Shop", "96,43");

Second,

you can modify existing data and this will be reflected in the result, e.g. you can change the buying price in our example and the changed revenues are visible in all components bound to your result data source.


Preparation of the Target Data Source

In the target data source you should create the columns and add one dummy row. Scorecard does not see the measure w/o at least one row.


Script:

selection in the UI5 Table triggers the value population to input components (input field and slider)



var selection = UI5TABLE_BUY.getSelectionDimensionMembers();
selection.forEach(function(dim, im) {
   var product = dim.member;
  
   var buingPrice = 0.0;
 
   var buyRows = DATAITERATOR_BUY.getRows().containing({ 
    "dimensions": [ 
        { "key" : "Product", "value" : product } 
      ] 
    });
 
   // assuming only one!  
   buyRows.forEach(function(buyRow, index) {
  buingPrice = buyRow.getMeasureValue("Buying Price");
   });
   VALIINPUT_1.setValue(""+buingPrice);
   SLIDER_1.setValue(buingPrice);
  
});

then, change on any of those input components triggers update of the data source, e.g. slider:


var selection = UI5TABLE_BUY.getSelectionDimensionMembers();
selection.forEach(function(dim, im) {
   var prod = dim.member;
  
   DS_BUY.addRow(prod, ""+SLIDER_1.getValue(), true);
});

the "true" parameter on 3rd place means "overwrite"

Now, as the data iterators are triggering data change events - the result data source will recalculate everything again and populate to the components - and this is how it works.

also this example is available in the repository for use:

applications/SCN_WHAT_IF-20160310175332.zip at master · org-scn-design-studio-community/applications...

Have Fun!