Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Applies to:
SAP Netweaver BW. For more information, visit the Business Intelligence homepage.
Summary
In quite a few of the Sales requirement, users will ask for Calendar week analysis and reports based on
Calendar week. Such requirements will be satisfied using standard time characteristics viz 0CALWEEK,
0CALQUARTER.
But in certain scenarios, users will ask for Fiscal Week and to achieve the same we need to write logic based
on the Date, Fiscal Year and Fiscal Year variant. This article addresses the requirement of Fiscal Week and
Fiscal quarter in BW/BI Reports.
Author Bio
Sohil is working as SAP Netweaver BW consultant at Deloitte Consulting India Pvt. Ltd. He
has an experience around 6 years in the field of SAP.
He is the technical reviewer of an SAP Press book “A Practical Guide to SAP Netweaver
Business Warehouse 7.0”
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 1
Step by Step Guide to Fiscal Week and Fiscal Quarter
Table of Contents
Introduction ......................................................................................................................................................... 3
Business Requirement ........................................................................................................................................ 3
Step by Step guide ............................................................................................................................................. 3
Fiscal Week Code: .......................................................................................................................................... 5
Fiscal Quarter Code: ....................................................................................................................................... 6
Appendix ............................................................................................................................................................. 9
Other useful Function Modules for dates: ....................................................................................................... 9
Related Content ................................................................................................................................................ 12
Disclaimer and Liability Notice .......................................................................................................................... 13
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 2
Step by Step Guide to Fiscal Week and Fiscal Quarter
Introduction
This article addresses the requirement of Fiscal Week and Fiscal quarter in BW/BI Reports.
Business Requirement
In quite a few of the Sales requirement, users will ask for Calendar week analysis and reports based on
Calendar week. Such requirements will be satisfied using standard time characteristics viz 0CALWEEK,
0CALQUARTER.
But in certain scenarios, users will ask for Fiscal Week and to achieve the same we need to write logic based
on the Date, Fiscal Year and Fiscal Year variant.
Difference
If, for a given client, the Fiscal Year (FY) is not same as that maintained in standard SAP system then Fiscal
week and Calendar week would be different.
For example, if SAP standard FY Variant K4 is used then the FY would be January to December but if for a
client the Fiscal Year is, say July to June, and say defined FY Variant is “XY” then in BW we can neither
directly use 0CALWEEK for Weekly reporting requirements nor can directly have any time conversion,
instead we need to derive Fiscal Week code based on the Date, FY and FY Variant.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 3
Step by Step Guide to Fiscal Week and Fiscal Quarter
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 4
Step by Step Guide to Fiscal Week and Fiscal Quarter
DATE2 = SOURCE_FIELDS-FKDAT.
FISCV = SOURCE_FIELDS-PERIV.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 5
Step by Step Guide to Fiscal Week and Fiscal Quarter
**Get the difference between the first and input date (given data record date)
**Get the rounded off value to get the total number of weeks.
DAYS = DAYS + 1.
WEEKS = DAYS / 7.
NUMBER = DAYS MOD 7.
**Get the Fiscal week for an input date by concatenating Year and Week found in above
step
CONCATENATE YEAR WEEKS INTO RESULT.
DATE2 = SOURCE_FIELDS-FKDAT.
FISCV = SOURCE_FIELDS-PERIV.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 6
Step by Step Guide to Fiscal Week and Fiscal Quarter
* E_BUPER =
E_GJAHR = YEAR
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**Get the difference between the first date and input date (given data record date)
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = DATE1
* TIME1 =
DATE2 = DATE2
* TIME2 =
IMPORTING
DATEDIFF = DAYS
* TIMEDIFF =
* EARLIEST =
EXCEPTIONS
INVALID_DATETIME = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**Get the rounded off value to get the total number of weeks.
DAYS = DAYS + 1.
WEEKS = DAYS / 7.
NUMBER = DAYS MOD 7.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 7
Step by Step Guide to Fiscal Week and Fiscal Quarter
**Get the Quarter based on the found week in above step for an input date (given
record date)
IF WEEKS BETWEEN '01' AND '13'.
CONCATENATE YEAR '1' INTO RESULT.
ELSEIF WEEKS BETWEEN '14' AND ’26’.
CONCATENATE YEAR '2' INTO RESULT.
ELSEIF WEEKS BETWEEN '27' AND ’39’.
CONCATENATE YEAR '3' INTO RESULT.
ELSEIF WEEKS BETWEEN '40' AND ’53’.
CONCATENATE YEAR '4' INTO RESULT.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 8
Step by Step Guide to Fiscal Week and Fiscal Quarter
Appendix
Other useful Function Modules for dates:
RSARCH_DATE_SHIFT: To get the Date/Week Shift
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 9
Step by Step Guide to Fiscal Week and Fiscal Quarter
If I_WEEKDAYS = 1 & I_NUMBER_OF_WEEKDAYS = n, where n is any whole number, then it will always
show nth week‟s Monday irrespective of date.
Example 2:
I_DATE = 09/06/2010
I_WEEKDAY = 2
I_NUMBER_OF_WEEKDAYS = 0
I_FLG_STAY_IN_MONTH = „„
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 10
Step by Step Guide to Fiscal Week and Fiscal Quarter
If I_WEEKDAY > 1 & I_NUMBER_OF_WEEKDAYS = n, where n is any whole number, then it will show nth
week date based on I-WEEKDAY value.
If entered date is Monday, I_NUMBER_OF_WEEKDAYS = 0 and I_WEEKDAY = 2 then it will show the
same week Tuesday i.e. 09/07/2010 in our example.
If entered date is Monday, I_NUMBER_OF_WEEKDAYS = 3 and I_WEEKDAY = 2 then it will show after 2
week‟s Tuesday i.e. 09/20/2010 in our example.
Like this few more combinations can be made as per the requirements.
WEEK_GET_FIRST_DAY: To get the First date of the Calendar Week
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 11
Step by Step Guide to Fiscal Week and Fiscal Quarter
Related Content
Help on SAP
Calendar Week / Fiscal Week
Fiscal Week / Fiscal Quarter
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 12
Step by Step Guide to Fiscal Week and Fiscal Quarter
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 13