This blog provides a step by step guide on how to use customer exit variables in BW reports and how to restrict key figures based on user input in other variables.
In a BW Sales Analysis report, user wants to analyze the Sales$ based on the calendar day range they entered on the report selection screen and put it in Column A. They would also like to have a separate column (Column B) in the report to view the Sales$ from the previous 12 months based on the date range they selected.
For example: User selected 01/02/2012 – 03/31/2012 as the date range on the selection screen. Then for Column A, the report will display Sales$ from date range 01/02/2012 to 03/31/2012 and for Column B, it will display Sales$ from Calendar Month 01/2011 to 12/2011.
We can use Customer Exit Variables to achieve this.
Step-by-Step Guide
1. Create a restricted key figure using key figure Shipped Sales $ and restrict it by Calendar day (0CALDAY) with variable 0I_DAYS
The BW report selection screen should look like the following:
2. Create a new variable for info object 0CALMONTH. We will use it to populate the previous 12 months. Make sure to select Customer Exit from the Processing By drop down list and choose Selection option from the variable represents drop down .
3. After the variable is created, we need to write the code to populate the previous 12 months for variable ZPRE12_MONTH_CDAY.
Run T-Code CMOD –> Create a project if none exists –> Components –> EXIT_SAPLRRS0_001 (Enhancement for Global Variables in Reporting) –> ZXRSRU01
The logic will be as follows:
- Retrieve the date range user entered on the report selection screen. In this case, the info object is 0CALDAY and variable is 0I_DAYS.
- Calculate the previous 12 month range based on the “date from” value user entered.
4. Create another restricted key figure and restrict it by Calendar month and use the variable created (In this case: ZPRE12_MONTH_CDAY).
5. Add the two restricted key figures created to the report.
Summary
In this example, we used Customer Exit Variable to restrict certain key figures based on user input in other selection variables. With Customer Exit Variables, we can write custom ABAP code to dynamically populate the values and add additional logic as needed. Everything is being handled in the background and it is completely transparent to the user. No additional user input is required. It is a relatively simple process and can become very handy when creating heavily customized BW reports.