Professional Documents
Culture Documents
Customer Exit Variables in SAP BW/BI Reports - First Day of The Current/Previous Month
Customer Exit Variables in SAP BW/BI Reports - First Day of The Current/Previous Month
Applies to:
SAP BW 7.0 and will also work on BW 3.5. For more information, visit the EDW homepage.
Summary
This article explains step by step process about how to use Customer Exit Variables in SAP BW/BI reports.
Author Bio
Prakash Kumar Sahu is a SAP BI consultant with more than 2 years of SAP BI/BW experience and
currently working with Tata Technologies Limited (Pune/India). He has got rich experience and
worked on various BW/BI implementation/Support projects.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 1
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Table of Contents
Introduction: ........................................................................................................................................................ 3
Business Scenario: ............................................................................................................................................. 3
Steps:………….. ................................................................................................................................................. 3
Code:…………… ................................................................................................................................................ 6
Testing of Code: ................................................................................................................................................. 9
Report Designer: ............................................................................................................................................... 12
Execute the Report: .......................................................................................................................................... 13
See the Report Result: ..................................................................................................................................... 13
Related Content ................................................................................................................................................ 14
Disclaimer and Liability Notice .......................................................................................................................... 15
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 2
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Introduction:
This article explains requirement of Customer Exit Variables in BW/BI reports. We will learn how to use
characteristic Customer Exit variables in our BI reports.
Customer Exit Variable: In BI project, consultant often come across the situation when they need to use a
processing type other than manual entry / default value, replacement path, SAP exit, or authorization to fulfill
the requirement of the customer, then a customer exit gives you the option of setting up a processing type for
variables, tailor-made to your specific needs.
Business Scenario:
In many BI reports (For example Sales Report) user want to see the MTD (Month-To-Date) sales data. For
th st
example if user runs the sales report on 7 April, 2011 then report should give the sales data from 1 April,
th st
2011 to 6 April, 2011. Similarly if user runs the sales report on 1 day of any month then report should give
st
the sales data of all the days of last month. For example, if user runs the report on 1 April, 2011 then report
st st
should give the sales data from 1 March, 2011 to 31 March, 2011.
In order to reflect the data in our BI report as per above requirement, we need to use the Customer Exit
Variable on Calendar Day (0CALDAY)
Steps:
1.Create Customer Exit Variable on Calendar Day (0CALDAY)
Create Z_FDCPM (First Day of Current\Previous Month). The properties of the variable are as below:-
Type of Variable : Characteristic
Variable Name : Z_FDCPM
Processing By : Customer Exit
Characteristic : Calendar Day
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 3
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 4
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
1.6 Make the settings as below in the Details Tab. Leave the other tabs in its default settings. Click OK.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 5
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Code:
Go to T-Code CMOD in BW and then give your Project Name and click on Change button.
Click on Components.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 6
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
*---------------------------------------------------------- *
* INCLUDE ZXRSRU01 *
*---------------------------------------------------------- *
yyyy(4) TYPE n,
mm(2) TYPE n,
dd(2) TYPE n,
CASE i_vnam.
* (If Date is first day of the month then it gives first day
WHEN 'Z_FDCPM'.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 7
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
IF i_step = 2.
REFRESH e_t_range.
dd = sy-datum+6(2).
mm = sy-datum+4(2).
yyyy = sy-datum+0(4).
CLEAR : fst_date.
CONCATENATE yyyy mm '01' INTO fst_date.
begdt = fst_date.
CLEAR: ls_ra_sid.
ls_ra_sid-sign = 'I'.
ls_ra_sid-opt = 'EQ'.
ls_ra_sid-low = firdt.
CLEAR: ls_ra_sid-high.
APPEND ls_ra_sid TO e_t_range.
ENDIF.
ENDCASE.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 8
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Testing of Code:
We will test our codes to check if our customer exit variable works as per the given requirement or not. We
will provide the date manually and will check for its return value. Following are some test cases.
Input Date Expected output date
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 9
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Enter the t-code RSRT in BW, give the query name and press enter. After this, click on Execute + Debug.
Press F5 one by one till cursor points to ENDFUNCTION. When cursor points to ENDFUNCTION then click
F8 to continue.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 10
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Double click on the variable during the debugging to get the current value of the variable at that instant. After
debugging is complete we get the values of variables as below.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 11
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Report Designer:
In Report Rows: Drag and Drop Calendar Day and Factory Characteristics.
In Report Columns: Drag and Drop Quantity key figure.
In Report Fitter: Restrict the 0CALDAY(Calendar day) with a range whose lower limit is Customer Exit
Variable Z_FDCPM(First Day of Current\Previous month) and upper limit is 0DAT (Current Calendar Day)
with offset -1. Please note that 0DAT gives today’s date so 0DAT-1 will give yesterday’s date.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 12
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
th st
See the date ranges in the report. Report was executed on 7 April, 2011 so it is giving data from 1 April,
th
2011 to 6 April, 2011.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 13
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
Related Content
https://www.sdn.sap.com/irj/sdn/index
Implementing Customer Exit Reporting Variables as Methods
SAP Library - Customer Exits
SAP Library - BI Suite - Reporting Variables-Customer Exits
For more information, visit the EDW homepage
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 14
Customer Exit Variables in SAP BW/BI Reports – First day of the Current/Previous Month
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 15