09-04-2008 2:39 PM
Hi ABAP Experts,
is there any FM or code which can determine how many i.e. fridays are in a month?
thanks,
YNS
09-04-2008 3:01 PM
Hello
parameters: p_mon like marv-lfmon.
parameters: p_gja like marv-lfgja.
data: date like sy-datum,
day type p,
counter type i.
concatenate p_gja p_mon '01' into date.
do.
day =date mod 7.
if day > 1.
day = day - 1.
else.
day = day + 6.
endif.
if day = 5.
counter = counter + 1.
endif.
date = date + 1.
if date+4(2) > p_mon.
exit.
endif.
enddo.
write: 'there is', counter, 'fridays'.
09-04-2008 2:43 PM
i dont think there is fm for that
use fms
DAY_ATTRIBUTES_GET
DATE_COMPUTE_DAY
check first day of month using above fm and then you can caluculate
09-04-2008 3:01 PM
Hello
parameters: p_mon like marv-lfmon.
parameters: p_gja like marv-lfgja.
data: date like sy-datum,
day type p,
counter type i.
concatenate p_gja p_mon '01' into date.
do.
day =date mod 7.
if day > 1.
day = day - 1.
else.
day = day + 6.
endif.
if day = 5.
counter = counter + 1.
endif.
date = date + 1.
if date+4(2) > p_mon.
exit.
endif.
enddo.
write: 'there is', counter, 'fridays'.
09-04-2008 3:14 PM
Hi Maroz,
Nice one, But this may lead to an Infinite loop if the Month entered is '12'
Just a small Correction to the above Code ..
if date+4(2) NE p_mon instead of
if date+4(2) > p_mon.
09-04-2008 3:29 PM
Thanks,
is there any possibility to see on which date is for example the second friday?
BR,
YNS
09-04-2008 3:32 PM
Hi Younes,
When ever the Counter variable becomes 2, that DATE will be your second friday ..
09-04-2008 3:41 PM
Hi,
Yes
what does this do?
else.
day = day + 6.
endif.
so i uderstood that friday is always when result of Mod = 5.
so basically if i want to count the number of tuesdays it would be then 2?
thanks for your clarification.
BR,
Younes
09-05-2008 5:34 AM
Hello
Yes
1 - monday
2 - tuesday
3 - wednesday
4 - thursday
5 - friday
6 - saturday
7 - sunday
09-05-2008 11:27 AM
Thanks for your comment.
what if i wanted to make the interval of the months variable.
if i have custom defined start and end of months.
and this is maintained in a table? Fiscal Year Variant (See T009B)
thanks,
BR,
YOunes