2016 Mar 31 10:45 PM
Hello SCN-Community,
I'm looking for a data-type that allows me to display a time difference (calculated in seconds) in an internal table respectively ALV in format hh:mm:ss.
How can I implement that?
Example:
Calculated time difference: 60 seconds
Should be display as: 00:01:00
Thanks a lot!
Regards,
Philipp
2016 Apr 02 12:03 AM
ABAP provides many implicit conversions. In your case, just play with the primitive types T and I:
DATA t TYPE syuzeit. " it's a type T with output length 8 so that to output hh:mm:ss
DATA i TYPE i.
i = 60.
t = i.
WRITE t. " will display 00:01:00
2016 Apr 01 12:29 AM
data: lv_sec type sy-tabix value '60',
lv_hhmmss type swl_pm_cvh-duration.
CALL FUNCTION 'MONI_TIME_CONVERT'
EXPORTING
ld_duration = lv_sec
IMPORTING
lt_output_duration = lv_hhmmss.
2016 Apr 02 1:54 PM
2016 Apr 02 2:07 PM
By the way, don't use non-released function modules (see their attributes), as in new releases SAP delete some of them, or make them obsolete (usage is then signaled by upgrade tools like SolMan CDMC) which are subject to be later deleted. It's better to use supported things (like the ABAP statement I mentioned previously). Or if you really need a function module, create a custom one which does the ABAP code.
2016 Apr 04 7:28 AM
2016 Apr 01 4:35 AM
Hello,
Is that field which you assign the difference is a time field or any integer one?
I think if we assign directly to a time field it should convert to time, i.e, 60 seconds as 00:01:00.
Thanks,
Srikanth.
2016 Apr 01 4:53 AM
Hi Philipp,
Try this FM MONI_TIME_CONVERT.
DATA : LV_DRTN TYPE SY-TABIX,
LV_TIME TYPE SWL_PM_CVH-DURATION.
CALL FUNCTION 'MONI_TIME_CONVERT'
EXPORTING
LD_DURATION = LV_DRTN
IMPORTING
LT_OUTPUT_DURATION = LV_TIME
.
Thanks,
Ananthachari
2016 Apr 02 12:03 AM
ABAP provides many implicit conversions. In your case, just play with the primitive types T and I:
DATA t TYPE syuzeit. " it's a type T with output length 8 so that to output hh:mm:ss
DATA i TYPE i.
i = 60.
t = i.
WRITE t. " will display 00:01:00