Business Scenarios:
1. Populate a release date value for a given combination of data selected from two
different data streams.
a. Data stream1 for the given selection has the release date characteristic
b. Data stream2 for the given selection or for any other selection doesn’t
have release date characteristic
2. Populate the value for a keyfigure based on the G/L Account value within the
query output
Cube A has the release date characteristic and is loaded via a flat file.
Cube B does not have the release date characteristic and would need maximum value of
the data coming through for a given combination of characteristics.
Step 1: Add the characteristic to Cube B and set the transformation or update rules
mapping to initial value with no update happening to the field. The characteristic is added
to the cube only to have it in the structure for reporting purposes (To drag it over in the
query).
Step 2: Create a DSO and load the data from the flat file which actually has the
data to get the combination of Characteristic A and Characteristic B as Key fields of DSO
and the date value to be maximum in the aggregation definition of the keyfigure (date).
By doing so, the DSO will contain the unique combination of Characteristic A
and Characteristic B with the maximum value of release date available for reference.
Step 1: Add the keyfigure to the Cube in consideration and similar to the step1
above no update needs to happen within the transformation or update rules.
Step 3: Need to use this keyfigure in the queries to trigger the code in BadI.
The rest of the steps are going to be common for both the phases.
Step 4: Go to transaction code SE18 and select the option “BAdI Name” and enter
the BAdI name as “RSR_OLAP_BADI” and click on display button.
Step 5: In the next screen go to menu and click on “Implementation” and then
select the option “Create” if a previously implemented option/filter does not exist.
If you click on “Create”, a new screen opens up asking you to enter the name of the
implementation for the original BadI “RSR_OLAP_BADI”.
Name the BadI as “ZVAR_IMPL” (BADI for Virtual Char & KYFG’s implementation)
and in the next screen define the filter as “Z*” as shown in the screenshot below by
clicking on the insert row button in the screen:
Step 6: Now click on the tab “Interface” and you can define the name of the
implementing class as “ZCL_IM_VAR_IMPL” as shown in the screenshot below:
Double click on the implementation class and you can see the default methods available
in the screen for
DEFINE
INITIALIZE
COMPUTE
Each of this default methods have parameters which can be leveraged for filtering and
other data processing.
Before going into parameters / attributes available for methods, we will look into the
actual definition of the class ZCL_IM_VAR_IMPL,
In the above screenshot the attributes are added as per the requirement, in the first
scenario of virtual char implementation the attributes to be added would be:
P_CHA_0ME_MED_ISS
P_CHA_SP_TERRTY
P_CHA_SPRELDATE
In the second scenario of virtual keyfigure implementation the attributes added are:
P_CHA_0CHRT_ACCTS
P_CHA_0GL_ACCOUNT
P_KYF_0QUANTITY
P_KYF_SP_VR_QTY
Now, parameters for the method DEFINE are:
FLT_VAL Value of the MultiProvider for which the BadI is to be executed. We can
use this as a case scenario and have different coding functionality within the Method
based on the MultiProvider name.
I_S_RKB1D Has list of components other than MultiProvider for filtering if required.
The possible columns which can be used for filtering are:
I_TH_CHANM_USED is of the type RRKE_TH_CHANM which in turn maps to the
table RSDCHA for looking up the characteristic existence in the system.
C_T_CHANM and C_T_KYFNM are the characteristic and keyfigure tables respectively
which would be updated by the list of characteristics and keyfigures required for the
derivation or calculation of the virtual fields for reporting.
I_TH_SFC Would be the internal table which will have all the values from the
C_T_CHANM.
I_TH_SFK Would be the internal table which will have the values from the
C_T_KYFNM table.
I_S_DATA This would be the table in which the position of the fields to be updated
along with other data is being determined.
I_PARTCUBE This would be the partial cube within the MultiProvider if the filtering
has to be cube specific within the MultiProvider.
I_S_RKB1D This would be similar to the one mentioned in Define and Initialize
sections.
Other than the basic methods available in the class, additional methods have been
implemented to attain the functionality w.r.to virtual chars/keyfigures.
The following are the custom methods implemented for the class:
1. CONSTRUCTOR - Constructor
2. GET_FIELD_POSITION_D
3. DEF_CHECK_CHA
4. DEF_CHECK_KYF
5. DEF_ADD_CHA
6. DEF_ADD_KYF
The source code for the standard methods and the custom method will be provided in the
later part of this document.
First, we will be looking into the parameters of the custom methods which have been
implemented:
None.
I_FIELDNM It uses the P_CHA and the actual characteristic or P_KYF and the
keyfigure to populate the concatenated attribute for later use in the COMPUTE method
and also for position generation.
I_S_DATA internal table to hold the characteristics and keyfigures defined in the
section.
R_POSITION Position of the fields w.r.to the usage of the method
Parameters of DEF_CHECK_CHA:
CHATAB Table to be referenced for looking up the characteristic
CHA_NAME Name of the characteristic to be looked up
FLAG Flag value set either to X or blank which is later used in Define method
Parameters of DEF_CHECK_KYF:
Parameters of DEF_ADD_CHA:
Parameters of DEF_ADD_KYF:
*----------------------------------------------------------------------*
* Method IF_EX_RSR_OLAP_BADI~DEFINE
* Author : Dharma Teja Atluri *
* Date : Aug 14, 2008 *
* Technical Contact : SAP BI Support *
* Functional Contact : NA *
* RICE ID : NA *
* *
* Purpose :
*----------------------------------------------------------------------*
* Modification Log *
* *
* Changed On Changed By CTS Description *
* ---------------------------------------------------------------------*
* 07/22/2008 DATLURI BDVK915309 Initial implementation *
* TPR 28165
* 07/08/2010 DATLURI BDVK919311 TPR 41836 - Royalty qty *
* calculation based on G/L Account mapping table ZBW_QRY_GL_MAP *
*----------------------------------------------------------------------*
method IF_EX_RSR_OLAP_BADI~DEFINE.
CASE i_s_rkb1d-infocube.
WHEN 'ZM_IPSPRI'.
IF FLT_VAL = 'ZM_IPSPRI'.
CLEAR: L_CHAR_EXISTS.
IF L_CHAR_EXISTS = 'X'.
ELSE.
CLEAR: L_CHAR_EXISTS.
ENDIF.
ENDIF.
* This implementation is for SPL Detail related queries relevant for Royalty qty
WHEN 'ZMSLDTLS'.
IF FLT_VAL = 'ZMSLDTLS'.
CLEAR: L_KYF_EXISTS.
IF L_KYF_EXISTS = 'X'.
ELSE.
CLEAR: L_KYF_EXISTS.
ENDIF.
ENDIF.
ENDCASE.
endmethod.
*----------------------------------------------------------------------*
* Method IF_EX_RSR_OLAP_BADI~INITIALIZE
* Author : Dharma Teja Atluri *
* Date : Aug 14, 2008 *
* Technical Contact : SAP BI Support *
* Functional Contact : NA *
* RICE ID : NA *
* *
* Purpose :
*----------------------------------------------------------------------*
* Modification Log *
* *
* Changed On Changed By CTS Description *
* ---------------------------------------------------------------------*
* 07/22/2008 DATLURI BDVK915309 Initial implementation *
* TPR 28165
* 07/08/2010 DATLURI BDVK919311 TPR 41836 - Royalty qty *
* calculation based on G/L Account mapping table ZBW_QRY_GL_MAP *
*----------------------------------------------------------------------*
method IF_EX_RSR_OLAP_BADI~INITIALIZE.
IF FLT_VAL = 'ZM_IPSPRI'.
ENDIF.
IF FLT_VAL = 'ZMSLDTLS'.
ENDLOOP.
ENDIF.
endmethod.
method IF_EX_RSR_OLAP_BADI~COMPUTE.
IF FLT_VAL = 'ZM_IPSPRI'.
IF SY-SUBRC EQ 0.
clear: l_spreldat01.
l_spreldat01 = l_spreldt.
<l_SPRELDATE> = l_spreldat01.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
* The code below is for ZMSLDTLS royalty G/L Account related quantity calculation
IF FLT_VAL = 'ZMSLDTLS'.
IF SY-SUBRC EQ 0.
clear: l_qtyvr.
l_qtyvr = 0.
<l_quantityvr> = l_qtyvr.
ELSE.
clear: l_qtyvr.
l_qtyvr = <l_quantityor>.
<l_quantityvr> = l_qtyvr.
ENDIF.
ENDIF.
ENDIF.
endmethod.
method CONSTRUCTOR.
endmethod.
method GET_FIELD_POSITION_D.
IF r_position IS INITIAL.
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.
endmethod.
method DEF_CHECK_CHA.
endmethod.
method DEF_CHECK_KYF.
endmethod.
method DEF_ADD_CHA.
l_s_chanm-chanm = cha_name.
if readonly = 'X'.
l_s_chanm-mode = rrke_c_mode-read.
else.
l_s_chanm-mode = rrke_c_mode-no_selection.
endif.
READ TABLE chatab ASSIGNING <l_s_chanm>
WITH KEY chanm = l_s_chanm-chanm.
IF sy-subrc <> 0.
APPEND l_s_chanm TO chatab.
ELSEIF readonly <> 'X'.
<l_s_chanm>-mode = rrke_c_mode-no_selection.
ENDIF.
endmethod.
method DEF_ADD_KYF.
l_kyfnm = kyf_name.
READ TABLE kyftab
WITH KEY table_line = l_kyfnm
TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
APPEND l_kyfnm TO kyftab.
ENDIF.
endmethod.