Hi BW/BI gurus,
Currently, The Query look like below:-
User need to enter Fiscal Year, and in this example, User entered Fiscal Year: 2012
How the Query currently Look likeThe Cal year/mth is automatically generated based on the Fiscal Year entered
What I need to find out 3 things:-
1. No of Days in Calendar Year/Month
2. No of Days in Year
3. No of Months
The current Codes I have is the find all these 3 things based on User Manual Input for Cal Year/Mth
1. No of Days in Calendar Year/Month
1. No of Days in Calendar Year/Month
WHEN 'ZVAR_NO_DAYS_FIRST_CAL_MTH'.
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = '0PCALMON'.
CLEAR l_s_range.
zcalyear = loc_var_range-low(4).
zcalmonth2 = loc_var_range-low+4(2).
CONCATENATE zcalyear zcalmonth2 '01' INTO zcalday.
IF zcalmonth2 BETWEEN 01 AND 03.
zcalyear = zcalyear - 1.
ENDIF.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
day_in = zcalday
IMPORTING
last_day_of_month = zcalday1
EXCEPTIONS
day_in_not_valid = 1.
CONCATENATE zcalyear '0401' INTO zcalday2.
zdays = zcalday1 - zcalday2 + 1.
l_s_range-low = zdays.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
CLEAR: zcalyear, zcalmonth, zcalmonth2, zdays.
2. No of Days in Year
WHEN 'ZVAR_NO_DAYS_YR_FR_CAL_MTH'.
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = '0PCALMON'.
CLEAR l_s_range.
CONCATENATE loc_var_range-low '01' INTO zcalday.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = zcalday
i_monmit = '00'
i_periv = 'V3'
IMPORTING
e_gjahr = zfiscyear.
* e_buper = zfiscper3.
IF zfiscyear MOD 4 = 0 AND NOT zfiscyear MOD 100 = 0.
zdays = 366.
ELSE.
zdays = 365.
ENDIF.
l_s_range-low = zdays.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDLOOP.
CLEAR: zcalday, zdays, zfiscyear.
3. No of Months
WHEN 'ZVAR_NO_MONTHS_FIRST_CAL_MTH'.
LOOP AT i_t_var_range INTO loc_var_range
WHERE vnam = '0PCALMON'.
CLEAR l_s_range.
zcalyear = loc_var_range-low(4).
zcalmonth2 = loc_var_range-low+4(2).
CONCATENATE zcalyear zcalmonth2 INTO zcalday1.
IF zcalmonth2 BETWEEN 01 AND 03.
zcalyear = zcalyear - 1.
ENDIF.
CONCATENATE zcalyear '04' INTO zcalday2.
CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = zcalday1
i_datum_von = zcalday2
* I_KZ_INCL_BIS = ' '
IMPORTING
e_monate = months.
l_s_range-low = months + 1.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
EXIT.
ENDLOOP.
CLEAR: zcalday1, zcalday2, zcalmonth2, zcalyear.
But Right now, I need to change the Query so that the User Only need to enter: Fiscal Year.
And the Query will display accordingly.
Can anyone please advice on how to modify the codes? to get the data from the Columns based on Fiscal Year entered instead of data coming from Manual Input?
Many thanks,
Vince