Example: The InfoSet ( ZV_IS1) is based on two ODSs (Product-ZV_OPD and Shipper-ZV_OSHPR) . The requirement is to create a virtual Key Figure [Discounted Price ZVPRV] which is a part of the Shipper ODS( ZV_OSHPR) which will filled up at runtime.
The algorithm of the calculation is a complex calculation and based on a Function Module(ZV_FMPRC1). Moreover ZV_FMPRC1 will input the Product No and Shipper Number, access database table and perform complex calculations and the output would be the required ZVPRV.
To complete the task please use the following methods:
1. Create a Key Figure (ZVPRV) and attach to the Shipper ODS.
2. TCode: SE19 create an implementation using definition RSR_OLAP_BADI.
3. TCpode: SE24 Create the follwing attributes by modifying the generated class name in Step 2.
For Key Figure:
Attribute : P_KYF_ZV_IS1___F38
Level : Instance Attribute
Visibility : PublicAssociation
type : I
For Characteristics:
Attribute : P_CHA_ZV_IS1___F1
Level : Instance Attribute
Visibility : PublicAssociation
type : I
Similarly you can create other Characteristic.
Note: Remember to follow the syntax for:
Key Figure P_KYF_
Characteristics P_CHA_
Visibility of the attributes must be Public rather than private
Association must be I
Level should be Instance Attribute
You can find the name of the key figure and characteristics from the query designer view of the InfoSet. As InfoSet uses a different Technical name than the underneath ODSs. In this case it uses ZV_IS1___F38 for the key figure ZVPRV, ZV_IS1___F1 for Shipper ID for example.
Step 4. Go to the Methods Section and Double Click on the Method
[IF_EX_RSR_OLAP_BADI~DEFINE]. Sample code can be used by editing the required changes.
CASE i_s_rkb1d-infocube.
WHEN 'ZV_IS1'. " When using the InfoSet
l_s_chanm-chanm = 'ZV_IS1___F1'.
l_s_chanm-mode = rrke_c_mode-read.
APPEND l_s_chanm TO c_t_chanm.
l_s_chanm-chanm = 'ZV_IS1___F37'.
l_s_chanm-mode = rrke_c_mode-read.
APPEND l_s_chanm TO c_t_chanm.
l_kyfnm = 'ZVPRV'.
l_s_chanm-mode = rrke_c_mode-no_selection.
APPEND 'ZV_IS1___F38' TO c_t_kyfnm.
WHEN OTHERS.
ENDCASE.
Step 5. Go to the Method [ IF_EX_RSR_OLAP_BADI~COMPUTE] and add the sample code .
FIELD-SYMBOLS
FIELD-SYMBOLS
FIELD-SYMBOLS
DATA: l_zv_20dv TYPE curr09.
ASSIGN COMPONENT P_CHA_ZV_IS1___F1 OF STRUCTURE c_s_data TO
ASSIGN COMPONENT P_CHA_ZV_IS1___F37 OF STRUCTURE c_s_data TO
ASSIGN COMPONENT p_kyf_zv_is1___f38 OF STRUCTURE c_s_data TO
CALL FUNCTION 'ZV_FMPRC1'
EXPORTING
prdt =
shipper =
IMPORTING
avg_val = l_zv_20dv.
Step 6: Now you can add the Key Figure to the query and use it.
No comments:
Post a Comment