Skip to Content
author's profile photo Former Member
Former Member

FM to find n.of working days

Hi experts,

Is there any FM to find n.of working days between two given dates?

Regards

Add comment
10|10000 characters needed characters exceeded

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 11:41 AM

    Hi ravi,

    1. Not only the number of days,

    but also the list of dates.

    WORKING DAYS based upon the calendar id.

    2. This program

    (it has an independent form)

    which will give such thing.

    3. Just copy paste in new program.

    REPORT abc.

    data : num type i.

    parameters : frdate type sy-datum default '20051216'.

    parameters : todate type sy-datum default '20051221'.

    perform getinfo using frdate todate changing num.

    break-point.

    &----


    *& Form getinfo

    &----


    • text

    ----


    FORM getinfo USING fromdate todate CHANGING numofdays type i.

    DATA : d TYPE sy-datum.

    d = fromdate - 1.

    DO.

    d = d + 1.

    IF d > todate.

    EXIT.

    endif.

    CALL FUNCTION 'DATE_CHECK_WORKINGDAY'

    EXPORTING

    date = d

    factory_calendar_id = '01'

    message_type = 'I'

    EXCEPTIONS

    date_after_range = 1

    date_before_range = 2

    date_invalid = 3

    date_no_workingday = 4

    factory_calendar_not_found = 5

    message_type_invalid = 6

    OTHERS = 7.

    IF sy-subrc = 0.

    numofdays = numofdays + 1.

    write :/ d.

    ENDIF.

    ENDDO.

    ENDFORM. "getinfo

    regards,

    amit m.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 11:40 AM

    Hi,

    you can use this FM.

    DATE_CHECK_WORKINGDAY

    Regards,

    Sumit.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      See sample code below:

      report zcalculate_days.

      • Sample code to calculate total working days and holidays between 2 dates.

      data: total_days(4) type c,

      v_holidays type i,

      v_work_days type i,

      v_total_days type i.

      data: begin of holidays occurs 0.

      include structure iscal_day.

      data: end of holidays.

      parameters: from_dt like sy-datum,

      to_date like sy-datum,

      calendar like scal-hcalid.

      start-of-selection.

      • Get total days between 2 dates

      call function 'DAYS_BETWEEN_TWO_DATES'

      exporting

      i_datum_bis = to_date

      i_datum_von = from_dt

      i_kz_excl_von = '0'

      i_kz_incl_bis = '1'

      i_kz_ult_bis = ' '

      i_kz_ult_von = ' '

      i_stgmeth = '0'

      i_szbmeth = '2'

      importing

      e_tage = total_days

      exceptions

      days_method_not_defined = 1

      others = 2.

      • Get Holidays between 2 dates

      call function 'HOLIDAY_GET'

      exporting

      holiday_calendar = calendar

      factory_calendar = calendar

      date_from = from_dt

      date_to = to_date

      tables

      holidays = holidays

      exceptions

      factory_calendar_not_found = 1

      holiday_calendar_not_found = 2

      date_has_invalid_format = 3

      date_inconsistency = 4

      others = 5.

      describe table holidays lines v_holidays. "Total holidays

      v_total_days = total_days. "Total days

      v_work_days = total_days - v_holidays. "Total working days

      write:/ 'Start date : ', from_dt.

      write:/ 'End date : ', to_date.

      write:/ 'Calendar : ', calendar.

      write:/ 'Total days : ', v_total_days.

      write:/ 'Working days : ', v_work_days.

      write:/ 'Holidays : ', v_holidays.

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 11:50 AM

    Hi,

    You can get holidays between 2 dates using function module HOLIDAY_GET

    Get total number of days between 2 dates and then deduct the number of holidays the result is number of working days.

    Hope this helps.

    regards

    Damasus

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 11:37 AM

    Hi Ravi,

    It might not getting the FACTORY CALENDAR. Make sure that factory calender exists.

    Rgds,

    Prakash

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 12:13 PM

    hi,

    You might not have passed the parameter factory calender id to the function module.

    Regards,

    Sailaja.

    Add comment
    10|10000 characters needed characters exceeded