on 06-10-2015 12:46 PM
Hi,
I have a data source with the following dimensions in my SAP Design Studio dashboard:
Key 1 (String) | Key 2 (String) | Measure 1 (int) |
KEY_1 | Description 1 | x |
KEY_2 | Description 2 | y |
KEY_3 | Description 3 | z |
KEY_4 | Description 4 | w |
I would really like to display the different keys in text fields because I am going to display the descriptions. After a heavy amount of searching online, I have come to an understanding that getting dimension values is quite difficult. (I am not trying to get the measure which easily can be obtained with the DS_1.getData() method)
A work around I have found is to use the following code:
var Dim_For_Description= DS_1.getMembers(Dimension, 100);
Dim_For_Description.forEach(function(Dim_Desc, Dim_i) {
if(Dim_i==1){Desc_1= Dim_Desc.internalKey;}
else if(Dim_i==2){Desc_2= Dim_Desc.internalKey;}
else if(Dim_i==3){Desc_3= Dim_Desc.internalKey;}
else if(Dim_i==4){Desc_4= Dim_Desc.internalKey;}
else if(Dim_i==5){Desc_5= Dim_Desc.internalKey;}
else if(Dim_i==6){Desc_6= Dim_Desc.internalKey;}
else if(Dim_i==7){Desc_7= Dim_Desc.internalKey;}
else if(Dim_i==8){Desc_8= Dim_Desc.internalKey;}
else if(Dim_i==9){Desc_9= Dim_Desc.internalKey;}
else if(Dim_i==10){Desc_10= Dim_Desc.internalKey;}
});
The problem is that the DS_1.getMembers() sorts the members alphabetically while I need them to be according to the sorting in the DS.
Is there any work-sround for this problem?
I am using Design Studio 4.1
Thank you.
Hi Martha,
It is a known limitation of the getMembers() function that the sort order is based on the master data and not the data source. I don't believe there is a workaround to get the data source order.
Can I ask why you don't just display the data in a Crosstab component?
Regards,
Mustafa.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mustafa,
The reason i cannot use a crosstab is because I need the values into variables for a global script. The values will for instance decide which CSS class I am going to apply to certain components etc etc.
In addition to this, I am going to display certain values in text fields in different places on the dashboard, so a crosstab will not cover these requirements.
Regards,
Martha
Hi Mustafa,
The Key 2 is sorted according to Key 1. This means that for each Key 1 (sorted in ascending order), there should be one description (Key2). Key 1 is sorted alphabetically, which it is supposed to be, but Key 2 is not meant to be alphabetically.
If there had been a method which allowed me to get the dimension value, that would have been perfect.
DS_1.getData(Key 2, {Key 1="Key_01"})
Sadly, Design Studio does not support that for some reason, and I am left to find another way to obtain my dimension values.
Thank you for trying to help me.
Martha.
Hi Martha,
Okay, so the penny just dropped and I have realised that we don't even need to add a key value measure to your BEx Query. Going by your example of a need for DS_1.getData(Key 2, {Key 1="Key_01"}), my understanding is that all you really want to be able to do is explicitly lookup the description for a particular key when needed. This can be achieved using the Collection Utility and JSON Object components from the Design Studio SDK Development Community.
Basically, the idea is that we populate a Collection component with key/description pairs which can be accessed via a lookup.
My test application looks like this:
The steps are as follows:
1. Add a Collection and JSON Object component to your application as shown below:
2. Code the "On Startup" event script of the application as follows to populate the collection:
var myMembers = DS_1.getMembers("ZOSTATE", 100);
myMembers.forEach(function(member, index) {
JSONOBJECT.addProperty("ZOSTATE", member.internalKey);
COLLECTION.addItem(member.internalKey, member.text, DS_1.getData("006EIC2OSTY2YB65GRCSC3OO2", JSONOBJECT.getAsMultiDimFilter()).value);
});
I have included a measure value for completeness based on your data source table example. If you don't need this then you can do away with the JSONOBJECT component and simply code the script as follows:
COLLECTION.addItem(member.internalKey, member.text, 0.0);
3. As an example of how to look up the description for a particular key, a button "On Click" script is coded as follows (but you can adapt as needed):
var memberInfo = COLLECTION.getEntryByKey("CO");
TEXT_1.setText(memberInfo.key + " - " + memberInfo.label + " ( " + memberInfo.value + " )");
Let me know if this addresses your requirement,
Mustafa.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.