Skip to Content
0

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

Feb 14, 2017 at 07:40 PM

416

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

7 Answers

Tammy Powlas
Feb 14, 2017 at 08:05 PM
0

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

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

I am trying to establish an interaction between Crosstab and Chart within the same application.

Upon selecting each Transc ID from the Crosstab,the respective values should be changed in Chart.By default I would like to show the first Transc Id values in the chart but not all the values.

Data-source is universe.

0

As you can see in this thread, the crosstab has some limitations - https://archive.sap.com/discussions/thread/3774909 - I will keep looking, hopefully others will reply

0
Mustafa Bensan Feb 15, 2017 at 02:35 AM
0

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.

Show 1 Share
10 |10000 characters needed characters left 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.

0
Mustafa Bensan Feb 17, 2017 at 03:06 AM
0

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.

Show 1 Share
10 |10000 characters needed characters left 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.

0
Mustafa Bensan Feb 18, 2017 at 02:18 AM
0

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.

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

Hi Mustafa,

Code has been updated as suggested for Logic 2.

Please find the required screenshots.

Code for On Data change of DATAITERATOR :

Initial View of Crosstab:

Initial View of Chart:

Properties of crosstab:

Chart Properties:

Thanks.

0

Hi Poojitha,

From your Initial View screenshots it looks like in data source DS_1_CROSSTAB the first Transaction ID is 7000031888. Are you sure this same Transaction ID exists in data source DS_2_CHART? I don't see it in the Initial View.

0

Hi Mustafa,

We do have have the value is DS_2_CHART. The values were not sorted initially.

Attached the screen shot of the initial view of the chart after sorting.

Thanks

0

Can you place the following code immediately after setFilter() and let me know the result?:

APPLICATION.Alert(defaulttrans);

Also, please provide a screenshot of the Property Sheet for the Data Iterator component.

0

Since the first row is not selected by default, I end up getting "Too Much Data" after executing the report until the first row is clicked.

chart-message.jpg (21.1 kB)
0

Since the chart component is only ever supposed to show data for one Transaction ID, you should not include the Transaction ID in the Rows panel of the data source initial view. This should resolve the "Too much data" issue on startup.

By the way, what dimension is intended to be the chart category axis (x-axis) dimension?

0

Hi Mustafa,

The Category X Axis for the chart is the selected Transaction ID and the Person Resp for that ID.

Y Axis is the Actual and the Additional Hours for each Person.

xy-axis-chart.png (48.4 kB)
0
Mustafa Bensan Feb 21, 2017 at 04:35 AM
0

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);

}
Show 7 Share
10 |10000 characters needed characters left characters exceeded

Hi Mustafa,

Thanks for your inputs. I have followed the steps you mentioned, but when I execute the report, I get the below error message at run time.

Steps:

Code:

Note: Crosstab has the below code for interaction with the chart.

DS_2_CHART.setFilter("_F2TMQOAxEeaDs7wYTcl-yw", CROSSTAB_1.getSelectedMember("_F2TMQOAxEeaDs7wYTcl-yw"));

Thanks.

0

Hi Poojitha,

It seems like the crosstab script is being executed before the chart data source is loaded. Can you confirm where exactly you are executing the crosstab interaction code?

Are you receiving the error because you are clicking on the crosstab before the chart is populated?

Regards,

Mustafa.

0

Hi Mustafa,

The crosstab interaction code is on the On Select of Crosstab.

Initially the chart is not loaded.I get the error once I click on the crosstab.

Thanks.

crosstab.jpg (122.8 kB)
0

Poojitha,

The chart SHOULD be loaded initially if you have implemented my code as specified. Have you assigned data source DS_1_CROSSTAB1 to the Data Iterator component? Can you provide screenshots of the following?:

1) The property sheet of the Data Iterator component;

2) The definition of the global script variable chartinit.

Thanks,

Mustafa.

0

Hi Mustafa,

Here are the screenshots:

Thanks.

0

Poojitha,

Can you update your code as follows and let me know whether the alert message is triggered?

if(!chartInitialized){
   
APPLICATION.Alert("DS 2 loading triggered");

    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);}

Also, change the Use Mock Data property of the Data Iterator to false.

0
Show more comments
Mustafa Bensan Feb 23, 2017 at 03:13 AM
0

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.

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

The application has few other basic scripts like components.setvisible(false). No other scripts are included in the application startup.

Below is the initial view of the application after using the updated code. I have not clicked on the crosstab

initial-screen.jpg (94.9 kB)
0

And you didn't see any alert message?

0

No, there was no alert message dispalyed.

0

This could be a volume issue if the data iterator "On Data Change" event is not being triggered. How many data cells are shown in the Initial View of data source DS_1_CROSSTAB1?

0
Mustafa Bensan Feb 23, 2017 at 08:15 AM
0

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);

}
Show 7 Share
10 |10000 characters needed characters left characters exceeded

Hi Mustafa,

Reiterating on the steps you mentioned from the beginning to ensure I am doing it right-

* Load in Script of DS2_Chart is false

*Deleted the Data Iterator

* Placed the below code in the DS2_Chart On Result Set Changed

Below is the message on run time:

Thanks.

ds2-chart.jpg (62.1 kB)
runtime.jpg (20.2 kB)
0

Poojitha,

My instructions were as follows:

1) The Load in Script property of data source DS_2_CHART should be set to TRUE (which appears to be the case from the screenshot);

2) The script should be placed in the "On Result Set Changed" event of data source DS_1_CROSSTAB1 and NOT DS_2_CHART. At the moment it has been placed in the chart data source so this is why you are seeing the "Data source not loaded" message.

Also, just for good measure, make sure the Members for Filtering option of dimension TransactionID for data source DS_1_CROSSTAB1 is set to "Posted values only" in the Initial View.

Regards,

Mustafa.

0

Hi Mustafa,

1) DS2_Chart Load in Script set to TRUE.

2) DS1_CROSSTAB1 On Result Set Changed code

3) Members for Filtering option of dimension TransactionID for data source DS_1_CROSSTAB1 is set to "Posted values only" in the Initial View.

At Runtime:

ds2-chart.jpg (30.9 kB)
ds1-crosstab.jpg (62.6 kB)
runtime.jpg (123.8 kB)
0

Hi Poojitha,

Can you run the application in local mode and let me know if you see any error messages in the Error Log window of the Design Studio IDE?

Thanks,

Mustafa.

0

Hi Mustafa,

All the while I was executing the application locally and I do not see the error message in the error log window of Design studio.

Thanks

0

Please add the following code immediately before the DS_2_CHART.loadDataSource() line:

APPLICATION.alert(transactionIDkey);

Let me know the result.

0
Show more comments