09-14-2008 10:40 AM
hello all experts,
please tell me how to calculate no of sundays in a month when i have month its start & end date & year
thanking you,
gaurav
09-14-2008 11:00 AM
09-14-2008 11:00 AM
09-14-2008 11:05 AM
Hi Gaurav,
I don't know about FM which does this but the logic can be simple.
Loop all the days between your two dates and for each date just call FM DATE_COMPUTE_DAY which returns 7 if it is Sunday.
To increase the date please use FM CALCULATE_DATE.
Regards,
Karol
P.S.: If people answer your question please close the question as answered (It is not good to have all questions open if they are already answered ...)
09-14-2008 1:09 PM
try this:
data : lf_date type dats,
counter type i value 0.
select-options: so_date for lf_date default '20080901' to '20080920'.
data :working_days like standard table of RKE_DAT with header line.
data : days type i,
month type i,
year type i,
cal_days type i.
*Total no. of days b/w dates
CALL FUNCTION 'HR_AUPBS_MONTH_DAY'
EXPORTING
BEG_DA = so_date-low
END_DA = so_date-high
IMPORTING
NO_DAY = days
NO_MONTH = month
NO_YEAR = year
NO_CAL_DAY = cal_days
.
*Total no. of working days b/w dates
CALL FUNCTION 'RKE_SELECT_FACTDAYS_FOR_PERIOD'
EXPORTING
I_DATAB = so_date-low
I_DATBI = so_date-high
I_FACTID = 'ST'
TABLES
ETH_DATS = working_days
EXCEPTIONS
DATE_CONVERSION_ERROR = 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.
loop at working_days.
read table working_days.
counter = counter + 1.
endloop.
write:/ working_days-PERIODAT,
/ counter,
/ cal_days.
here 'ST' is the factoru calender.
hope this serves your purpose.
Sid
09-14-2008 1:17 PM