Hi,
Just to be sure, you are implementing the Virtual Characteristics BAdI. If I am right, you implemented BAdI RSR_OLAP_BADI.
First remark, I advice to implement the new (kernel-based) BAdI RSROA_OLAP_BADI instead of classic BAdI RSR_OLAP_BADI. Please refer to SAP Note 1717880 - Virtual Key Figures & Characteristics for more information.
Did you implement any coding in method IF_EX_RSROA_OLAP_BADI~INITIALIZE (please note that I am referring to the new BAdI as example)? Your coding should look like this (also according to the sample implementation):
METHOD IF_EX_RSROA_OLAP_BADI~INITIALIZE.
* Local data declaration
DATA:
l_global_name TYPE string,
l_error TYPE rs_bool.
FIELD-SYMBOLS:
<l_global> TYPE i,
<l_s_sfc> TYPE rrkg_s_sfc.
* Get field postions for Characteristics in structure
LOOP AT i_th_sfc ASSIGNING <l_s_sfc>
WHERE user_exit NE rrke_c_mode-none. "#EC CI_HASHSEQ
CONCATENATE 'P_CHA' <l_s_sfc>-chanm INTO l_global_name SEPARATED BY '_'.
UNASSIGN <l_global>.
ASSIGN (l_global_name) TO <l_global>.
CHECK <l_global> IS ASSIGNED.
TRY.
<l_global> = <your_query_name>=>get_field_position_d(
i_fieldnm = <l_s_sfc>-keyreturnnm
i_s_data = i_s_data ).
CATCH cx_rs_not_found.
<l_global> = 0.
ENDTRY.
ENDLOOP.
And you need of course method GET_FIELD_POSITION_D. Your coding should look like this (also according to the sample implementation):
METHOD GET_FIELD_POSITION_D.
* Local data declaration
DATA:
l_r_tdescr TYPE REF TO cl_abap_typedescr,
l_r_sdescr TYPE REF TO cl_abap_structdescr,
l_t_components TYPE abap_compdescr_tab,
l_s TYPE string.
* Get position of the field in the structure
l_r_tdescr = cl_abap_typedescr=>describe_by_data( i_s_data ).
l_r_sdescr ?= l_r_tdescr.
l_t_components = l_r_sdescr->components.
READ TABLE l_t_components TRANSPORTING NO FIELDS
WITH KEY name = i_fieldnm.
IF sy-subrc GT 0.
CONCATENATE 'I_S_DATA' i_fieldnm INTO l_s SEPARATED BY '-'.
RAISE EXCEPTION TYPE cx_rs_not_found
EXPORTING
object = 'FIELD'
key = l_s.
ENDIF.
* Return position value
r_position = sy-tabix.
ENDMETHOD.
I suggest to debug method IF_EX_RSROA_OLAP_BADI~INITIALIZE and see if the determination of positions in the structure is OK. I.e. a position > 0 is determined.
Last but not least, please also (or as a first action) regenerate your BEx Query using t/code RSRT. I have done this many times to get rid of issues which I could not explain.
Best regards,
Sander