Skip to Content

getData is a very useful method. However, I found it a little bit more complex than I thought initially. Thus, I did some tests to understand its behaviors.

There are 3 notes described in the content assistant.

This method specifies members in the internal format.

For dimensions that are not specified, their aggregates will be used, provided that the corresponding aggregates exists in the result set.

The requested data needs to be part of the retrieved result set. This is especially important when requesting hierarchy nodes. The hierarchy needs to be expanded in advance to show the required hierarchy node.

Besides these 3 points, I think the key idea is that getData is not really to query but just to search from result set. Thus, the wanted data cell must exist in the result set and must “logically” have only one corresponding cell (see Test 5). And getData will take whatever number from that data cell even if the value has been filtered (see Test 7).

Let’s start from the simplest one.

Test 1:

/wp-content/uploads/2015/09/test1_786935.png

Column: AMOUNT_SOLD

Row: Yr (with “Show Totals” checked)

DS_1.getData(“AMOUNT_SOLD”, {“YR”: “2003”}).value

Result: correct result

Test 2 & Test 3 & Test 4:

/wp-content/uploads/2015/09/test3_786937.png

Column: AMOUNT_SOLD

Row: Yr (with “Show Totals” checked), QTR (with “Show Totals” checked)

DS_1.getData(“AMOUNT_SOLD”, {“YR”: “2003”}).value

Result: correct result

DS_1.getData(“AMOUNT_SOLD”, {“YR”: “2003”,”QTR”: “1”}).value;

Result: correct result

DS_1.getData(“AMOUNT_SOLD”, {“QTR”: “1”}).value;

Result: no result

Test 5:

/wp-content/uploads/2015/09/test6_786938.png

Column: AMOUNT_SOLD

Row: QTR (with “Show Totals” checked), MONTH_NAME (with “Show Totals” checked)

DS_1.getData(“AMOUNT_SOLD”, {“MONTH_NAME”: “January”}).value;

Result: no result even though there is only one corresponding “January” data cell. All upper-level dimensions need to be specified in the selection

Test 6:

/wp-content/uploads/2015/09/test7_786939.png

Column: AMOUNT_SOLD

Row: Yr (with “Show Totals” checked), QTR (with “Hide Totals” checked)

DS_1.getData(“AMOUNT_SOLD”, {“YR”: “2003”}).value

Result: no result

Test 7:

/wp-content/uploads/2015/09/test8_786940.png

Column: AMOUNT_SOLD

Row: Yr, QTR (Filter Members: “1”)

DS_1.getData(“AMOUNT_SOLD”, {“YR”: “2003”}).value;

Result: The result value is the AMOUNT_SOLD of Year 2003, Q1 not whole year

Test 8:

/wp-content/uploads/2015/09/test9_786941.png

If the result set is too large, then no data will be shown in the Result Set. Thus, getData won’t work even though we just need the value of one data cell.

One last thing.

Parameters of getData include “measure”, “dimension”, and “value for the dimension”. “Measure” and “value for the dimension” can be replaced by variable while “dimension” cannot. To solve this issue, we can use Design Studio SDK: JSON Object Component. (thank you Karol)

http://scn.sap.com/docs/DOC-63667

Without SDK:

var measure=”AMOUNT_SOLD”;

var year=”2003”;

DS_1.getData(measure,{“Yr”:year}).value

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

    1. Alfred Lee Post author

      Hi Alfons,

      Could you explain a little bit more? If there is no measure, then there should be no data presenting.

      Best,

      Alfred

      (0) 
    2. Alfons Gonzalez Comas

      Not exactly. Dataset query retrieves a single row with 4 columns (see picture)/wp-content/uploads/2015/10/kk_820533.jpg

      and I need to read their content. I suppose that i need to use another method as getDimension.Am I right?

      (0) 
      1. Alfred Lee Post author

        I am not able to reproduce your situation. But as it shows 0 data cell in the header, I think you won’t be able to use getdata. It seems to me the content you want to get is a member of those dimensions. So I suggest you to try getMembers.

        (0) 
        1. Alfons Gonzalez Comas

          Hi Alfred,

          getMemebrs works fine when a single dimension is used as a row. But when more than one dimensions appears on the view  arrays retrieved for each dimension using getMember are not consistent with view content. I mean

          Data view shows

          Dim1     Dim2     measure

          A1          B2          1

          A2          B1          1

          where

          getMembers(Dim1) provides an arary such as [A1,A2]

          and

          getMembers(Dim2) provides an arary such as [B1,B2]


          so how can i determine that A1 corresponds to B2 ?


          More details on Design Studio BIAL Question: How to iterate all cells? (UNX-based datasource)


          Alfons


          Thx

          (0) 

Leave a Reply