Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Data-Type to represent time difference

philippdoelker
Participant
0 Kudos
1,243

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

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
0 Kudos
965

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
7 REPLIES 7
Read only

Former Member
0 Kudos
965

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.

Read only

0 Kudos
965

This is exactly what is was looking for.

Thanks a a lot!

Read only

0 Kudos
965

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.

Read only

0 Kudos
965

Hello Sandra,

thanks for your advice!

Regards

Read only

0 Kudos
965

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.

Read only

former_member194965
Active Participant
0 Kudos
965

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

Read only

Sandra_Rossi
Active Contributor
0 Kudos
966

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