Skip to Content
avatar image
Former Member

How Many Fridays in a Month

Hi ABAP Experts,

is there any FM or code which can determine how many i.e. fridays are in a month?

thanks,

YNS

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 04, 2008 at 02: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'.
    

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • avatar image
    Former Member
    Sep 04, 2008 at 01: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

    Add comment
    10|10000 characters needed characters exceeded