For each transaction record, there are two DEC (length: 15, decimal digit: 0) data type fields in our datasource (PSA) which contain two different time values and in Transformation from this PSA to DSO, we would like to calculate the time difference between these two DEC type fields. Coud anyone here give us the ABAP routine on how to get the time difference?
In Transformation between the PSA and the DSO, in a field routine with these two DEC (length: 15, decimal digit: 0) data type fields as input, we find these two DEC type fields (we call them time1 and time2 respectively) are automatically converted as the P types as following:
* SOURCE_FIELDS-time1 TYPE P LENGTH 000008 DECIMALS 000000
* SOURCE_FIELDS-time2 TYPE P LENGTH 000008 DECIMALS 000000
Then we add our codes below:
data: lv_date_from type sy-datum,
lv_time_from type sy-uzeit,
lv_date_to type sy-datum,
lv_time_to type sy-uzeit,
lv_date_diff type i.
CONSTANTS : lc_zone type tzonref-tzone value 'UTC'.
CONVERT TIME STAMP SOURCE_FIELDS-time1TIME ZONE lc_zone INTO DATE lv_date_from TIME lv_time_from.
CONVERT TIME STAMP SOURCE_FIELDS-time2TIME ZONE lc_zone INTO DATE lv_date_to TIME lv_time_to.
CALL FUNCTION 'SCOV_TIME_DIFF'
EXPORTING
IM_DATE1 = lv_date_from
IM_DATE2 = lv_date_to
IM_TIME1 = lv_time_from
IM_TIME2 = lv_time_to
IMPORTING
EX_DAYS = lv_date_diff
EX_TIME = lv_time_diff
EXCEPTIONS
START_LARGER_THAN_END = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
Our question is how to get the time difference between time1 and time2 based on the above function output of lv_date_diff and lv_time_diff? Anyone could give us the succeeding coding here or any other idea to get the time difference?
We will give you rewards points for valuable answers!
Thanks!
Kevin