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.
CALL FUNCTION 'DATE_
EXPORTING
date = lv_startdate
IMPORTING
day = lv_day.
IF lv_day IS NOT INITIAL .
CASE : lv_day .
WHEN 1 ." Monday
CALL FUNCTION 'END_
EXPORTING
duration
unit
IMPORTING
end_date
end_time
CHANGING
start_date
start_time
EXCEPTIONS
factory_
date_out_of_
date_not_valid
unit_conversion_
si_unit_missing
parameters_no_
OTHERS
CONCATENATE enddate1
CONCATENATE enddate1
lv_starttime1 = lv_
lv_endtime1 = lv_
IF ( endtime1 GT lv_
CALL FUNCTION '
EXPORTING
utc_start = lv
CHANGING
utc_end = lv
hours = lv
ENDIF.
Post a Comment