calculate working days between two dates with abap



User Rating:  / 7
PoorBest 
Details

The following program calculates working days between two dates :

View source
REPORT zcalc_work_days.
*------------------------------------------------------------------------
*  www.developerpages.gr
*
*------------------------------------------------------------------------
 
data : w_days type i.
 
PARAMETERS f_date LIKE sy-datum.
PARAMETERS t_date LIKE sy-datum.
 
 
 
PERFORM calcworkdays USING f_date t_date CHANGING w_days.
write :/ ' Date From : ', f_date.
write :/ ' Date To   : ', t_date.
skip 1.
 
write :/ ' Working days   : ', w_days.
 
 
*&---------------------------------------------------------------------*
*&      Form  calcworkdays
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->FROMDATE   text
*      -->TODATE     text
*      -->DAYS       text
*----------------------------------------------------------------------*
FORM calcworkdays USING fromdate todate changing days.
  clear days.
  DATA : date_t TYPE sy-datum.
 
  date_t = fromdate.
 
  DO.
    IF date_t > todate.
      EXIT.
    ENDIF.
 
    CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
      EXPORTING
        date                       = date_t
        factory_calendar_id        = 'GR'
        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.
 
    add 1 to date_t.
 
    IF sy-subrc = 0.
      days = days + 1.
    ENDIF.
 
  ENDDO.
 
ENDFORM.                    "calcworkdays


You have no rights to post comments

   

Login  

   
   

     

© Developerpages