Monday, September 3, 2012

Calculating Number of Working Days in Query Level



if ( i_vnam eq 'ZWRKDDAYS' ).
  data: end_date type d,
        prev_wrk_day type sy-datum,
        start_date type d,
        bgn_of_month type sy-datum,
        num_of_days type d.
  concatenate sy-datum+0(6)  '01' into bgn_of_month.
  prev_wrk_day = sy-datum - 1.
  CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
    EXPORTING
     CORRECT_OPTION                     = '-'
      DATE                               = prev_wrk_day
      FACTORY_CALENDAR_ID                = '00'
   IMPORTING
     FACTORYDATE                        = end_date.
            .
  
  CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
    EXPORTING
     CORRECT_OPTION                     = '+'
      DATE                               = bgn_of_month
      FACTORY_CALENDAR_ID                = '00'
   IMPORTING
     FACTORYDATE                        = start_date.
            .
  num_of_days = end_date - start_date.
  e_t_data-sign = 'I'.
  e_t_data-opt = 'EQ'.
  e_t_data-low = num_of_days.
  append e_t_data to e_t_range.
  endif.



https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13579

No comments:

Post a Comment