Skip to Content
0

Design Studio 1.6 - Display corresponding column values of a specific Row from the query results

Oct 12, 2016 at 07:51 PM

460

avatar image

I have a BEx Query that returns 4 columns (2 Characteristics - Start Month (ZSTARTMON) & End Month (ZENDMON) and 2 Key Figures) as shown in the below example. This query runs before the application is loaded and always returns 24 rows (2 years) of data.

Environment: DS 1.6 SP3 & BEx Query

Note: "Row No" is for illustration purpose

I need to get the data from the 11th row and the last row (23rd row) from the above query result set and display them in the text boxes like shown below.

Basically I need to be able to get each individual corresponding column value of the 2 rows - 11th & 23rd and set those values in the individual text boxes. From the above result set it would return the following

Current Year : {TEXTBOX_1: 08/2015 , TEXT_2: 07/2015 , TEXT_3: “KF 1 value”, TEXTBOX_4: “KF 2 value”}

Previous Year: {TEXT_5: 08/2014, TEXT_6: 07/2014, TEXT_7: “KF 1 value”, TEXT_8: “KF 2 value”}

I wrote the below code which works (copied a few lines here) but I realized that it’s not a good practice as I have to duplicate the code for each variable (probably need 8 variables in this case) and repeat it for both the rows. Such a huge overhead and realized what if there are more KF columns and need to get multiple rows data for eg:- 1st, 7th etc., not ideal.

var CuYrStartMo=DS_1.getMembers("ZSTARTMON ", 24);

var CuYrEndMo=DS_1.getMembers("ZENDMON", 24);

CuYrStartMo.forEach(function(StartMoCY_element, index) {

CuYrEndMo.forEach(function(EndMoCY_element, index) {

if(index==23){

TEXT_1.setText(StartMoCY_element.internalKey);

TEXT_2.setText(EndMoCY_element.internalKey);

}

});

});

I'd like to achieve this in more cleaner and dynamic way rather than writing multiple & repetitive lines of code. I looked in to the concept of sing arrays & Global scripting but so far I haven’t been able to come up with a solution. Does anyone know how to achieve this? Any help would be appreciated.

Here are some of the links I referred to and a re helpful but they return the row data after making the selection on Crosstab whereas in my case I just have to read the rows without any user selection

https://archive.sap.com/discussions/message/16117362#16117362

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

Thanks,

Dilip

1.jpg (44.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Mustafa Bensan Oct 15, 2016 at 05:41 AM
0

Hi Dilip,

What you have described is to be able to iterate through a result set or lookup data from specific rows. As you have discovered there is not a very effective way of achieving this with standard functionality. I would recommend that you consider using the Design Studio 1.6 SDK Data Iterator component. It will allow you to reference specific rows and retrieve the key figure column values for those rows.

Regards,

Mustafa.

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

Thanks Mustafa for your response. Sure I will try the Data iterator component and let you know.

Thanks,

-Dilip

1

Hi Mustafa,

I tried the Data iterator component and have been getting the following error


  • Error during script processing. Contact the Application Designer to resolve the issue
  • Message: org.mozilla.javascript.EcmaError: SyntaxError: Empty JSON string (flatten#12)

In the above data iterator blog post link you provided, I see that couple of them had the same issue and posted it on the blog for help but not sure whether they were able to resolve it or not. I uninstalled & reinstalled it but no luck. Could you please help me out on this.

Thanks!

0

Hi Dilip,

Can you provide the script code you used with the Data Iterator?

Thanks,

Mustafa.

0