Skip to Content
author's profile photo Former Member
Former Member

DS GetMembers() and BEx condition - Do they work without conflict ?

Hi Experts

I have a Query with one Row - Customer and One Column - Sales . I have a condition in the Query for Top 3 Customers Based on the Sales Amount.

When I bring this Query to Design Studio , My initial View shows only 3 Customers ( as expected ). When I assign it to a Crosstab - it shows 3 customers ( as expected) .

But when I populate the customers using getMemberList() to a Listbox - I get all the customers.
When I write a script with getMembers() - I get all the Customers.

Question -

1.When the Query is restricted to only 3 customers , Shouldnt DS only fetch 3 customers all time?

2.If this is how getmember behaves, then the actual question is - For some purpose I want to pass this Top 3 customers from Design Studio to another Query as separate variables - How to achieve this without using getmembers() .

(I am using DS 1.5)

Thanks in advance for your valuable time,effort and answers 😊

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Jun 30, 2015 at 11:21 PM

    By the way, in addition to my previous comments, if your requirement is to allow selection of one of the top 3 customers from a list in order to pass to another query, then why not just use the Crosstab for the same purpose as the List Box?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 07, 2015 at 09:39 AM

    Hi Karthik, all,

    this what you describe is the correct behavior. You need to distinguish between functionality which is applied on Result Set and Members. Conditions are on Result Set. This is why the members are still there (just not displayed in result set). The members are read separately, independent of the result set - but through the query access.


    GetMembers are respecting only the settings you have in your query. The most important one are:

    Posted Values - members which are available in current result set, but before all other functions which are applied on the Result Set.

    Master Data - all members from master data (eg. used for filtering)

    With "Posted Values", there is another special case - in case you have an active filter on the dimension which you ask for members, this filter will be ignored. you can try it out.. here short recording.

    you can see, when I filter on the other dimension (pers) - the list (1.5 - data binding to dimension PROD) is changing (eg.. member 4 is gone). but when I filter on the used dimension, the members are still there (so the filter is ignored). This is, because in other case you would be not able to change any filter in this situation (as all members would disappear, only the filtered once would stay).

    It means, when you want to ask for members which are in current result set, you need to use a trick:

    in short - ask for members, loop on it, ask for data. if no data, nothing is in result set.

    // assure sums are shown

    DS_1.setTotalsDisplay("0BC_PROD1", TotalsDisplay.SHOW);

    // remove temporary the other from result set

    DS_1.removeDimension("0BC_PERS1");

    var members = DS_1.getMembers("0BC_PROD1", 999);

    LISTBOX_2.removeAllItems();

    members.forEach(function(element, index) {

    var data = DS_1.getData("4FW8C4WXM3HULQ4M1YPFT79EF", {"0BC_PROD1":element.internalKey});

    if(data.formattedValue != "") {

    LISTBOX_2.addItem(element.internalKey, element.text + " [" + element.externalKey + "]");

    }

    });

    then you can see the members which are in result set (and unfortunately a lot of warnings..).

    In addition, two more preconditions..


    * the code above is working only if sums are shown for the dimension (if the dimension is the first one)!

    DS_1.setTotalsDisplay("0BC_PROD1", TotalsDisplay.SHOW);

    * if the dimension is not the first one, you need to remove all other from resulset (to make the selection simple)

    DS_1.removeDimension("0BC_PERS1");

    Result:

    Helps?

    Karol


    me1.PNG (3.3 kB)
    me2.PNG (48.2 kB)
    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Karol,

      Thanks for the detailed explanation and workaround. Given the current getMembers() functionality, I think it would be useful if a new API method could be considered in future that allowed direct access to members from the result set after filters, conditions and other restrictions have been applied. The Top N customers example given in this question is a legitimate use case. I'm concerned that there could be a noticeable performance impact of looping through the entire result set when there are a large number of rows if only a small fraction of those rows are needed to be retrieved.

      Just a thought,

      Mustafa.

  • Posted on Jun 30, 2015 at 11:13 PM

    Hi Karthik,

    That's an interesting observation. Here are my thoughts regarding your questions:

    1. I was able to replicate the behaviour you've described. There is a known limitation of getMembers() not respecting sort order because it retrieves from the master data and not the result set. Perhaps the condition not being respected is related to this. Nevertheless, I agree that any active conditions should be respected by getMembers(), otherwise, as you've noted, the members returned are out of sync with those in the result set;

    2. As for other options, I tried applying the new data binding feature in DS 1.5 to populate a List Box and this also ignores the condition, as shown below:

    There doesn't seem to be any other way to easily access the data with condition applied. Given that the Crosstab binding works as expected yet the List Box binding does not, I am inclined to think this is a bug and would suggest opening an SAP Support Ticket in the absence of any further suggestions to achieve the requirement.

    I suppose a workaround could be to somehow write 3 separate BEx Queries, each returning the 1st, 2nd and 3rd customers if possible but this is not a very elegant solution. I think the preferred option would be to log this as a bug to have it reviewed accordingly.

    Regards,

    Mustafa.


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.