cancel
Showing results for 
Search instead for 
Did you mean: 

How to create loop in Design Studio

Former Member
0 Kudos

Dear Friends

I am currently working in SAP Design Studio 1.2 version and BW queries as source. I am in need to list last 36 months (like Aug 2013, Sep 2013, etc) on one of the drop down box and depends on which data will be displayed on dashboard. I get the latest month and year value from the source query but i do not see any option of creating loop or next\while such that i can do coding to produce it dynamically. I know that it is currently not available in 1.2 version but is there a way to do this?

Example : Current month is Apr 2013

I will require drop-down box  to show Apr 2013, Mar 2013 till . May 2010.

---

Regards

Kishore Balachandran

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kishore,

in consideration of the current restrictions of Design Studio 1.2, to achieve your requirement here is one solution:

  1. make sure that all the month values are available through a dimension in one of your data sources in order to fill a dropdown with those values (this can be achieved for example by using a customer exit interval variable which sets the start month and how many months backward should be included in the list of available values)
  2. then you need to set the sorting settings in the bex query for your month dimension, something like this:
  3. then you need to fill the dropdown with the values in design studio (without using the sort() function in design studio, because that would change the sort order that you already set in the query, and you need to sort by key but display text, so sorting needs to be done in the bex query):
    
    

    DROPDOWN_ZEITRAUM.setItems(DS_2.getMemberList("0CALMONTH", MemberPresentation.EXTERNAL_KEY, MemberDisplay.TEXT, 36));

    //DROPDOWN_ZEITRAUM.sort(false); // true=ascending; false=descending

  4. you should now see something like this in DS:

Currently you cannot add or exclude individual items separately to an existing list of dropdown values. You can only set the items of a dropdown with values coming from a dimension, so you always need to think in terms of how to achieve that one single dimension contains all the values and only those values that should be shown in your design studio dropdown component.

Looping as known from other programming languages ( for(...), while(...) ) is not available in Design Studio scripting in v1.2 (maybe in later versions).

But in some blog posts regarding the new event "doBackgroundProcessing" there is mentioned a way of looping, here the shorthand basics about it to have an idea about it (you keep incrementing a variable and calling an event several times where some code is executed until the condition for calling this event is no longer met and the "looping" ends):

On the "On Startup" script, please add: APPLICATION.doBackgroundProcessing();

Create a variable Variable1, initialize it to 0

Then, on the background processing function, add:

Variable1 = Variable1 + 1;

if (Variable1 < 7) {

  APPLICATION.doBackgroundProcessing();

}

Regards,

David Gyurasz

ely_turkenitz
Participant
0 Kudos

Hi David,

I know this thread has been 2 yrs old but we are currently running into a similar issue.

We are DS 1.6 and we don't use BW so there is no BEX query. Is there a way to achieve this result in Design Studio?

Thanks in advance.

MustafaBensan
Active Contributor
0 Kudos

Ely,

As this is a closed thread I suggest you post a new question, giving a specific example of the use case you need to implement so that you can receive broader visibility and responses.

Regards,

Mustafa.

ely_turkenitz
Participant
0 Kudos

Will Do. Thank you for the advice, Mustafa.

Answers (2)

Answers (2)

Former Member
0 Kudos

I'm going to have to think about this before I come up with a specific answer, but have you tried using recursion?

My mistake, I've been working with custom components and I was thinking you'd be able to call other functions. However, a custom component would be one way to accomplish your goal. It would be a bit of a pain, but you can use loops within them.

Former Member
0 Kudos

Hi,

I don't think you can do much in DS for your requirement (of looping). As an alternative, you can create a query in BW to give you these values and fill the DROPDOWN items.

Regards,

Former Member
0 Kudos

Hi Anil

I agree with you that BW can be the only solution at this point. We had already created a query which gives the last 36 months but we find trouble on arranging the order in design studio. By default, the query provides the list randomly and i tried arranging them on source's initial edit but when the same is set into drop-down box at start-up, it does not work.

I have requested BW side to check if this can be sorted in query itself but does this mean we cannot sort the data and load to components?

---

Regards

Kishore Balachandran

Former Member
0 Kudos

Hi Kishore,

Initial sorting will not make any effect when you set items in DROPDOWN component. The values are sorted by DS when populating the items in selection components.

There a sort control possible using DROPDOWN_1.sort() method. Just check if it fulfills your requirement.

Regards,