Skip to Content
0
Former Member
Jan 21, 2015 at 03:01 PM

BW query with ABAP

31 Views

Hello Experts,

I am trying to read data from the query with ABAP program which has 4 variables in the selection screen.

1.Key date

2.Currency

3.Hierarchy - Type of variable is Hierarchy and Single value

4.Hierarchy - Type of variable is Hierarchy node and multiple values

Hierarchy is based on cost units. The variable 4 will be based on the variable 3.

For example we have 4 hierarchies for cost units and for each hierarchy we have different nodes.

So based on the hierarchy we selectin variable 3 , the relevant nodes we can select in variable 4.

I have develoved the below program based on the inputs from

http://scn.sap.com/people/durairaj.athavanraja/blog/2005/12/05/execute-bw-query-using-abap-part-iii

I am facing challenge is passing the values for hierarchy and node. Please help.

DATA: wa_axis LIKE LINE OF r_dataset->n_sx_version_20a_1-axis_data .

DATA: wa_cell LIKE LINE OF r_dataset->n_sx_version_20a_1-cell_data .

DATA: wa_set LIKE LINE OF wa_axis-set.

CREATE OBJECT r_request

EXPORTING

i_genuniid = '7243KWKVL2R9VY4LFMPSWLOWR2'.

*Now set your variables if nessecary:

CLEAR wa_var.

wa_var-vnam = 'YDCDAT01'.

**

wa_var-sign = 'I'.

**

wa_var-opt = 'EQ'.

**

wa_var-low = sy-datum.

**

APPEND wa_var TO i_var.

CLEAR wa_var.

wa_var-vnam = 'YDYEFYR'.

wa_var-sign = 'I'.

wa_var-opt = 'EQ'.

wa_var-low = '2015'.

APPEND wa_var TO i_var.

CLEAR wa_var.

wa_var-vnam = 'YHYCOS'.

wa_var-sign = 'I'.

wa_var-opt = 'EQ'.

wa_var-low = 'COST UNIT'.

wa_var-high = '0HIER_NODE'.

APPEND wa_var TO i_var.

CLEAR wa_var.

wa_var-vnam = 'YHCOST'.

wa_var-sign = 'I'.

wa_var-opt = 'EQ'.

wa_var-low = 'C_10010'.

wa_var-high = '0HIER_NODE'.

APPEND wa_var TO i_var.

TRY.

r_request->variables_set( i_t_var = i_var ).

r_request->read_data( ).

r_dataset = cl_rsr_data_set=>get( i_r_request = r_request ).

r_dataset->refresh( i_version = 1 ).

CATCH cx_rsr_x_message INTO zcx_message.

CATCH cx_root INTO zcx_root.

ENDTRY.

CLEAR wa_axis .

LOOP AT r_dataset->n_sx_version_20a_1-axis_data INTO wa_axis .

IF wa_axis-axis EQ '001' .

LOOP AT wa_axis-set INTO wa_set .

ENDLOOP.

ENDIF.

ENDLOOP.

thank you