cancel
Showing results for 
Search instead for 
Did you mean: 

looping in design studio

Former Member
0 Kudos

Hi Gurus,

I have looked on SDN but could not find if there is a looping option in Design Studio.  What I am trying to do is to loop on result set to find out which entry in Column A is above 20.  The moment I put "For" in script window, I get error.  Has anyone ever done loops in Design studio?

Thank you for your suggestion.

Raj

Accepted Solutions (1)

Accepted Solutions (1)

Karol-K
Advisor
Advisor
0 Kudos

Hi Raj,

refer to help at http://help.sap.com/businessobject/product_guides/AAD14/en/ds14SP01_user_en.pdf

-> 27.3.1 Accessing Array Elements

the "loops" are possible by "forEach" statements, like this one:


var i = 2;

var e = "";

var array = DS_1.getMembers("0D_CUSTOMER", 100);

array.forEach(function(element, index) {

if (i == index) {

  e = element.externalKey;

}

});

APPLICATION.alert("Element with index " + i + " is \"" + e + "\".");

what you want to do is probably loop at members and ask for data:


array.forEach(function(element, index) {

if (i == index) {

  var dataCell = DS_1.getData("MEASURE", {"DIMENSION": element.internalKey });

  var value = dataCell.value;

}

});

Does it help you?

Karol

Former Member
0 Kudos

Hi Karol,

Thank you for yoru response!  what I am looking for example from the below table, read column B and if it is greater than 3 then get the corresponding value from Column A and put it in a list box.  So for below table the output will be green, white, and purple

Column AColumn BColumn C
Red 2Up
blue3Down
green 7Right
white5Left
purple8Center
Former Member
0 Kudos

Hi Raj,

I'm assuming that you are working with the following details:

  • Name of your data source is DS_1
  • Column B's values may be comma-separated by 1000s

Copy the following code and replace the technical names of columns A and B (without the '<>' brackets):


//Replace <Column A Technical Name> with the actual technical name of column A. Also adjust the maximum number of members from 300 to whatever value you wish

var Column_A_Members = DS_1.getMembers("<Column A Technical Name>", 300);

var Column_B_Value = 0.0;

//Replace <Column A Technical Name> & <Column B Technical Name> with the actual technical names of columns A&B

Column_A_Members.forEach(function(element, index) {

  Column_B_Value = Convert.stringToFloat(Convert.replaceAll(DS_1.getDataAsString("<Column B Technical Name>", {"<Column A Technical Name>": element}),",",""));

  if(Column_B_Value >= 3.0)

  {

  LISTBOX_1.addItem(element.internalKey, element.text);

  }

});

I hope this helps.

Thanks and Regards,

Eshwar Prasanna

Former Member
0 Kudos

Right on the money Eshwar!!! Thank you so much.  SOrry it took a little longer to respond as I was unavailable.

Answers (0)