Professional Documents
Culture Documents
1.1 S19 - BW - Query and Cust Exit Var
1.1 S19 - BW - Query and Cust Exit Var
Batch_2 Page 1
Pre session Q & A
Batch_2 Page 2
BW Query
Definition A query is the formal definition of a multidimensional query. You use analytic queries to analyze the data in the
SAP BW∕4HANA.
Exception
Batch_2 Page 3
BW Query Enhancement - Requirement
Sales Item Customer Exit (ABAP Layer, Can accept multiple values or ranges for a variable)
1. Take manual input from user for Fiscal period in a manual input variable.
This manual input variable must be auto populated with current fiscal period.
2. Get the fiscal period from the manual fiscal period variable and create a range (calculation)
Take the year and get the 1st period of the year (similar to YTD requirements) - This is the from value of the
interval.
Take the fiscal period entered in the manual fiscal period variable and treat this as To value of the interval.
Sales Header HANA Exit (AMDP based. HANA Layer and can only accept single value for a variable)
1. Get the calendar day input from user in a manual input variable.
This variable must be auto populated by current day -1.
2. Take the manual input calday and create a range:
From: Start of the year.
To: till the manual input calday
Batch_2 Page 4
BW Query Enhancement - BADI
• The only available extension RSR00001 (Customer Exit Global Variables in Reporting).
• Transaction SMOD.
• Function module EXIT_SAPLRRS0_001 gets called at execution time of a report)
The function block EXIT_SAPLRRS0_001 calls the include ZXRSRU01 which is in the
customer namespace to perform customization.
-----------------------------------------------------------------------------------------------------------------------------------
New Way:
• Via
Enhancement Spot: RSROA_VARIABLES_EXIT
BADI name: RSROA_VARIABLES_EXIT_BADI
BW4HANA BW/4HANA does not support the old implementation any longer which is based on SMOD.
Now, it's a prerequisite to create the enhancement implementation for the enhancement spot
RSROA_VARIABLES_EXIT_BADI if you want to work with customer exit variables
2. Create another manual input single value variable for 0FISCPER. This will be used to
capture input fisper from user:
Batch_2 Page 5
3. Now add these 2 in the filter in the BW Query:
6. On the tab 'Enhancement Spot Element Defnts', click on the 'BADI Implementation':
Batch_2 Page 6
8. Create an Enhancement Implementation by providing name and text.
The composite Enh Impl can be left blank.
9. Once created, select the created Enh Impl and click ok:
11. Now come out of this and go to tcode SE19 and provide the name of the Enhancement Implementation
and change it:
Batch_2 Page 7
Note: To extend the above functionality to Formula and Text variables of processing type Customer Exit the IOBJNM filter needs to be populated with the
values ‘1FORMULA‘ and ‘1TEXT‘ respectively in new Filter Combinations.
13. Now double click on 'Implementing Class' and write the code:
Method Signature
Batch_2 Page 8
Method Signature
Other variables
Sample Code
Batch_2 Page 9
Code Blocks
PUBLIC SECTION.
INTERFACES if_badi_interface .
INTERFACES if_rsroa_variables_exit_badi .
ENDCLASS.
METHOD if_rsroa_variables_exit_badi~process.
CASE i_vnam.
WHEN 'ZVAR_CE_I_FISPER'.
lv_fiscvar = 'K4'.
IF sy-subrc = 0.
CLEAR l_s_range.
ENDIF.
ENDIF.
ENDCASE.
ENDMETHOD.
Batch_2 Page 10
ENDMETHOD.
ENDCLASS.
public section.
interfaces IF_BADI_INTERFACE .
interfaces IF_RSROA_VARIABLES_EXIT_BADI .
class-methods ZV_IST1_ZV_CE_MI_S_FISCPER_BT2
importing
value(I_VNAM) type RSZGLOBV-VNAM
value(I_VARTYP) type RSZGLOBV-VARTYP
value(I_IOBJNM) type RSZGLOBV-IOBJNM
value(I_S_COB_PRO) type RSD_S_COB_PRO
value(I_S_RKB1D) type RSR_S_RKB1D
value(I_PERIV) type RRO01_S_RKB1F-PERIV
value(I_T_VAR_RANGE) type RRS0_T_VAR_RANGE
value(I_STEP) type I default 0
changing
!C_T_RANGE type RSR_T_RANGESID optional
!C_NO_SCREEN type RS_BOOL optional
!C_CHECK_AGAIN type RS_BOOL optional
!C_S_CUSTOMER type RRO04_S_CUSTOMER optional
raising
CX_RS_ERROR .
**********************************************************************
class-methods ZV_IST2_ZV_CE_I_FISCPER_BT2
importing
value(I_VNAM) type RSZGLOBV-VNAM
value(I_VARTYP) type RSZGLOBV-VARTYP
value(I_IOBJNM) type RSZGLOBV-IOBJNM
value(I_S_COB_PRO) type RSD_S_COB_PRO
value(I_S_RKB1D) type RSR_S_RKB1D
value(I_PERIV) type RRO01_S_RKB1F-PERIV
value(I_T_VAR_RANGE) type RRS0_T_VAR_RANGE
value(I_STEP) type I default 0
changing
!C_T_RANGE type RSR_T_RANGESID optional
!C_NO_SCREEN type RS_BOOL optional
!C_CHECK_AGAIN type RS_BOOL optional
!C_S_CUSTOMER type RRO04_S_CUSTOMER optional
raising
CX_RS_ERROR .
**********************************************************************
class-methods _TEMPLATE
importing
value(I_VNAM) type RSZGLOBV-VNAM
value(I_VARTYP) type RSZGLOBV-VARTYP
value(I_IOBJNM) type RSZGLOBV-IOBJNM
value(I_S_COB_PRO) type RSD_S_COB_PRO
value(I_S_RKB1D) type RSR_S_RKB1D
value(I_PERIV) type RRO01_S_RKB1F-PERIV
value(I_T_VAR_RANGE) type RRS0_T_VAR_RANGE
value(I_STEP) type I default 0
changing
!C_T_RANGE type RSR_T_RANGESID optional
Batch_2 Page 11
!C_T_RANGE type RSR_T_RANGESID optional
!C_NO_SCREEN type RS_BOOL optional
!C_CHECK_AGAIN type RS_BOOL optional
!C_S_CUSTOMER type RRO04_S_CUSTOMER optional
raising
CX_RS_ERROR .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
METHOD if_rsroa_variables_exit_badi~process.
**********************************************************************
* Main method which calls individual methods for every variable
**********************************************************************
CASE i_step.
ENDCASE.
TRY.
CALL METHOD (lv_method)
EXPORTING
i_vnam = i_vnam
i_vartyp = i_vartyp
i_iobjnm = i_iobjnm
i_s_cob_pro = i_s_cob_pro
i_s_rkb1d = i_s_rkb1d
i_periv = i_periv
i_t_var_range = i_t_var_range
i_step = i_step
CHANGING
c_t_range = <lt_data>
c_no_screen = c_no_screen
c_check_again = c_check_again
c_s_customer = c_s_customer.
CATCH cx_sy_dyn_call_illegal_method.
ENDTRY.
Batch_2 Page 12
ENDMETHOD.
METHOD zv_ist1_zv_ce_mi_s_fiscper_bt2.
**********************************************************************
* Method for variable: zv_ce_mi_s_fiscper_bt2 (i_step = 1)
**********************************************************************
lv_fiscvar = 'K4'.
IF sy-subrc = 0.
CLEAR l_s_range.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD zv_ist2_zv_ce_i_fiscper_bt2.
**********************************************************************
* Method for variable: zv_ce_i_fiscper_bt2 (i_step = 2)
**********************************************************************
IF sy-subrc = 0.
Batch_2 Page 13
IF sy-subrc = 0.
CLEAR l_s_range.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD _template.
**********************************************************************
* TEMPLATE METHOD.
* DO NOT MODIFY THIS CODE.
* FOR INDIVIDUAL METHODS, COPY THIS TEMPLATE METHOD
**********************************************************************
* ENDIF.
ENDMETHOD.
ENDCLASS.
HANA Exit CLASS zcl_var_hana_badi DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_badi_interface .
INTERFACES if_amdp_marker_hdb .
INTERFACES if_rsroa_var_hana_exit .
PROTECTED SECTION.
PRIVATE SECTION.
Batch_2 Page 14
PRIVATE SECTION.
ENDCLASS.
* <SIGNATURE>--------------------------------------------------------------------------------------- +
* | Instance Public Method ZCL_BPC_CL_RSROA_HANA_EXIT->IF_RSROA_VAR_HANA_EXIT~GET_PROPERTIES
* +------------------------------------------------------------------------------------------------- +
* | [--->] I_VNAM TYPE RSZVNAM
* | [--->] I_VARTYP TYPE RSZVARTYP
* | [--->] I_IOBJNM TYPE RSIOBJNM
* | [--->] I_INFOPROV TYPE RSINFOPROV
* | [--->] I_COMPID TYPE RSZCOMPID
* | [<-->] C_IS_ACTIVE TYPE RS_BOOL
* | [<-->] C_TS_VNAM_INDEX TYPE NT_TS_VNAM_INDEX
* +-------------------------------------------------------------------------------------- </SIGNATURE>
c_is_active := 'X';
IF :i_vnam = 'ZVAR_HE_S_CALDAY'
THEN
c_ts_vnam_index = SELECT 'ZVAR_HE_S_CALDAY' AS vnam, 1 as index from sys.dummy;
end if;
endmethod.
Batch_2 Page 15
METHOD if_rsroa_var_hana_exit~process BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT.
* Parameter c_value should specify the value of the variable.
c_value:= '';
IF :i_vnam = 'ZVAR_HE_S_CALDAY'
THEN
c_value := to_dats(add_days( current_date, -1 ));
END IF;
IF :i_vnam = 'ZVAR_HE_S_CALDAY_FR'
THEN
c_value := left(:i_var_value_1,4) || lv_day || lv_mth;
END IF;
IF :i_vnam = 'ZVAR_HE_S_CALDAY_TO'
THEN
c_value := :i_var_value_1;
END IF;
ENDMETHOD.
ENDCLASS.
Batch_2 Page 16