Header Ads

Good code for date and time calculation

*  Get day of the week
    CALL FUNCTION 'DATE_COMPUTE_DAY'
      EXPORTING
        date lv_startdate
      IMPORTING
        day  lv_day.
    IF lv_day IS NOT INITIAL .
      CASE : lv_day .

        WHEN 1 ." Monday
          CALL FUNCTION 'END_TIME_DETERMINE'
            EXPORTING
              duration                   = "variable "
              unit                       'H'
            IMPORTING
              end_date                   enddate1
              end_time                   endtime1
            CHANGING
              start_date                 sy-datum
              start_time                 sy-uzeit
            EXCEPTIONS
              factory_calendar_not_found 1
              date_out_of_calendar_range 2
              date_not_valid             3
              unit_conversion_error      4
              si_unit_missing            5
              parameters_no_valid        6
              OTHERS                     7.

          CONCATENATE enddate1 '180000' INTO lv_starttime11 .
          CONCATENATE enddate1 endtime1 INTO lv_endtime11 .

          lv_starttime1 lv_starttime11 .
          lv_endtime1   lv_endtime11.

          IF endtime1 GT lv_180000 ).

            CALL FUNCTION 'SCSM_TIME_DIFF_GET'
              EXPORTING
                utc_start lv_starttime1
              CHANGING
                utc_end   lv_endtime1
                hours     lv_hours.

          ENDIF.
Powered by Blogger.