Skip to Content

Interaction between chart and first default value of crosstab in SAP Design Studio 1.6

Hi All,

I am using SAP Design Studio 1.6 SP2 to develop a dashboard where I am using a crosstab and chart.

Cross tab(Crosstab_1) is mapped to one datasource (DS_1) and has the following details:

Transc ID ------------Support Team-----------Person Resp

700003XXX------------Team A ------------------A1

700003XXX ------------Team A ------------------B1

700004XXX------------Team B-------------------C1

700004XXX------------Team B-------------------D1

Chart(Chart_1) is mapped to a different datasource(DS_2) and has the following details:

Transc ID ------------Person Resp------------Actual Hours---------- Additional Hours

700003XXX------------ A1 --------------------2hrs---------------------5hrs

700003XXX ------------ B1 --------------------4hrs---------------------1hrs

700004XXX--------------C1 ------------------- 4hrs---------------------1hrs

700004XXX------------ D1-----------------------3hrs------------------------5hrs

I should be showing Chart_1 with only the first Transc Id by default.

As crosstab doesn't have the property to select the first row by default, I followed the steps in the below link and got the first row selected.(Which is now working for me)

https://blogs.sap.com/2015/05/14/css-tips-tricks-default-selection-in-a-crosstab-in-sap-businessobjects-design-studio/

Further, I would like to show the chart with the respective values of the first value selected in crosstab for which I have used the below in the On Select of chart_1

DS_2.setFilter("TranscID", CROSSTAB_1 .getSelectedMember("TranscID"));

But this doesn't work as expected. I have also referred the below discussion but I could not get it working.

https://archive.sap.com/discussions/thread/3737616

Can someone please suggest on this?

Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Feb 14, 2017 at 08:05 PM

    I'm not sure I follow correctly - are you trying to drill down? What is your data source? If it is BEx, you could use report-to-report interface (as Deepu explains here https://blogs.sap.com/2014/11/27/using-rri-to-jump-to-aolap-from-design-studio-14/ ); also the OpenDoc interface https://blogs.sap.com/2014/12/07/why-use-opendocument-with-design-studio/ which works with BEx/universe too

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 15, 2017 at 02:35 AM

    Hi Poojitha,

    If your Transaction IDs are sorted in ascending order, the following script code MIGHT work:

    var myDefaultSelection = DS_1.getMembers("TranscID",1); // Get first member
    DS_2.setFilter("TranscID", myDefaultSelection);         // Apply default transaction filter to chart data source

    If the above approach does not work then you can try the Design Studio 1.6 SDK – Data Iterator component to retrieve the first row of the data source as follows:

    1. Add the Data Iterator technical component to your application;

    2. Assign data source DS_1 to the the Data Iterator component;

    3. Execute the following code to show the default data in the chart:

    var rows = DATAITERATOR_1.getRows(0,1); // Return array with single row
    var defaultRow = rows[0];               // Retrieve individual row item of array
    var defaultTransaction = defaultRow.getDimensionValueKey("TranscID"); // Get key value of default selection
    
    DS_2.setFilter("TranscID", defaultTransaction); // Apply default transaction filter to chart data source 

    Regards,

    Mustafa.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Mustafa,

      Thanks for the detailed steps. I have tried both the logics you mentioned.

      Logic 1:

      I sorted the Transaction Ids in ascending order and used the two line code you mentioned on the "On Select" of chart datasource(DS_2) .

      Code:

      var mydefaultsel=DS_1.getMembers("GHI2TMQOAxEeaDs7wYTcl", 1); DS_2.setFilter("GHI2TMQOAxEeaDs7wYTcl",mydefaultsel);

      This still is showing all the values in the chart.

      Logic 2:

      I added the Data Iterator technical component to my application and used the code below on the "On Select" of chart datasource(DS_2) .

      Code:

      var rows= DATAITERATOR_1.getRows(0,1);

      var defaultRow= rows[0];

      var defaulttransc= defaultRow.getDimensionValueKey()

      But the last line of the code gives me an error. It does not allow me to add any dimension.(Ctrl+Space does not give a list of any dimensions)

      Could you please let me know what is missing?

      Thanks.

  • Feb 17, 2017 at 03:06 AM

    Hi Poojitha,

    For the two scenarios, please try the following updates:

    Logic 1:

    var mydefaultsel = DS_1.getMembers("GHI2TMQOAxEeaDs7wYTcl", 1); 
    var myFilter = mydefaultsel[0];
    DS_2.setFilter("GHI2TMQOAxEeaDs7wYTcl",myFilter.internalKey);

    Logic 2:

    In the Data Iterator component the Ctrl+Space content assist doesn't appear to be supported so you need to manually type the dimension technical ID. Your code should look like the following and should be placed in the "On Data Change" event of the data iterator:

    if (!chartInitialized) {
    
        var rows= DATAITERATOR_1.getRows(0,1);
        var defaultRow= rows[0];
        var defaulttransc= defaultRow.getDimensionValueKey("GHI2TMQOAxEeaDs7wYTcl");
    
        DS_2.setFilter("GHI2TMQOAxEeaDs7wYTcl",defaulttransc);
    
    }

    Note: chartInitialized should be defined as a Global Script Variable with default value false.

    Regards,

    Mustafa.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Mustafa,

      Thanks again for the details. Unfortunately, the chart is still showing data for all the values.

      Please find the steps followed :

      Logic 1:

      Step 1: Sorted the transaction IDs in ascending order.

      Step 2: Added the code to the Chart(On Select)

      When I execute the application the chart is still showing all the data but not the respective values of the first value of the crosstab.

      Logic 2:

      Step 1: Added the data iterator to the application.

      Step 2: Created a global script variable under the Application properties.

      Name - Chartintialized

      Type - Boolean

      Default Value -false

      URL Parameter - false

      Step 3: Under On Data Change of the DATAITERATOR_1 , I added the code you mentioned.

      (Is there anything that I have to add to the chart?)

      When I execute , the chart shows all the values.

      Thanks.

  • Feb 18, 2017 at 02:18 AM

    Hi Poojitha,

    Here are my comments:

    Logic 1

    In Step 2, the code should not be placed in the "On Select" event of the Chart. Instead place the following code in the "On Result Set Changed" event of data source DS_1:

    if(!chartInitialized){
    
        chartInitialized = true;
    
        var mydefaultsel = DS_1.getMembers("GHI2TMQOAxEeaDs7wYTcl", 1); 
        var myFilter = mydefaultsel[0];
        DS_2.setFilter("GHI2TMQOAxEeaDs7wYTcl",myFilter.internalKey);
    
    }

    Note: chartInitialized should be defined as a Global Script Variable with default value false.

    Logic 2

    Update the code as follows:

    if(!chartInitialized){
        
        chartInitialized = true;
    
        var rows= DATAITERATOR_1.getRows(0,1);
        var defaultRow=rows[0];
        var defaulttransc= defaultRow.getDimensionValueKey("GHI2TMQOAxEeaDs7wYTcl");
    
        DS_2.setFilter("GHI2TMQOAxEeaDs7wYTcl",defaulttransc);
    
    }

    Please provide screenshots of all of the script windows for Logic 2 so I can see the exact code that has been implemented.

    Additionally, please provide the following screenshots:

    1. Initial Views of data sources DS_1 and DS_2

    2. Property sheet for the Chart

    3. Property sheet for the Crosstab

    Regards,

    Mustafa.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 21, 2017 at 04:35 AM

    Hi Poojitha,

    It looks like the issue is due to the data source DS_2_CHART being loaded on startup. We need to apply the default filter at the same time as the load of DS_2_CHART. Here is what I suggest:

    1. Set the Load in Script property of data source DS_2_CHART to true;

    2. Place the following updated script code in the "On Data Change" event of the Data Iterator component:

    if(!chartInitialized){
       
        chartInitialized = true;    
    
        var rows = DATAITERATOR_1.getRows(0,1);
        var defaultRow = rows[0];
        var defaulttransc = defaultRow.getDimensionValueKey("_F2TMQOAxEeaDs7wYTcl-yw");    
        
        DS_2_CHART.loadDataSource();
        DS_2_CHART.setFilter("_F2TMQOAxEeaDs7wYTcl-yw", defaulttranc);
    
    }
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 23, 2017 at 03:13 AM

    Hi Poojitha,

    Are you seeing the alert message at all? Are you using any other script code in your application?

    Let's make sure the "On Data Change" event of the data iterator is being triggered. Please update the code as follows:

    APPLICATION.Alert("DS 2 loading triggered");  // Check event trigger
    
    if(!chartInitialized){
       
        chartInitialized = true;    
    
        var rows= DATAITERATOR_1.getRows(0,1);
        var defaultRow =rows[0];
        var defaulttransc = defaultRow.getDimensionValueKey("_F2TMQOAxEeaDs7wYTcl-yw");    
        
        DS_2_CHART.loadDataSource();
        DS_2_CHART.setFilter("_F2TMQOAxEeaDs7wYTcl-yw", defaulttranc);
    
    }

    Please send me a screenshot of your full screen application showing crosstab and chart after it it is launched and rendered. DO NOT click the crosstab component at this stage.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 23, 2017 at 08:15 AM

    Poojitha,

    Let's try another approach for testing purposes. Please do as follows:

    1. Remove the Data Iterator component;

    2. Instead, place the following code in the "On Result Set Changed" event of the data source DS_1_CROSSTAB1:

    if(!chartInitialized){
       
        chartInitialized = true;    
    
        var transactionID = me.getMembers("_F2TMQOAxEeaDs7wYTcl-yw", 1)[0];
        var transactionIDkey = transactionID.internalKey;
       
        DS_2_CHART.loadDataSource();
        DS_2_CHART.setFilter("_F2TMQOAxEeaDs7wYTcl-yw", transactionIDkey);
    
    }
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Mustafa,

      I updated the code and tried to execute , but I have come across a different scenario now.

      Please find the screenshots below:

      Updated Code:

      Alert message comes up after the prompts are entered and clicked on OK.

      Then, i get the below error message:

      When I remove the code from DS1_Crosstab1, the application executes without any errors.

      Thank you.

      updated-code.jpg (65.8 kB)
      alert.jpg (33.9 kB)
      error-msg.jpg (32.8 kB)