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

report

Former Member
0 Likes
587

Hi all,

My requirement is i want to convert 2900(means 29 min and 00 sec) into

00:29:00 ( 00 -


hrs,29 -


min, 00 -


seconds.).Pls explain with a sample code..

Regards & Thanks,

Alex

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
560

data p1(6) type c value '2900'.

data p2(8) type c.

data len type i.

datat off_set type i.

data dummy(6) type c value '0000'.

<b>* operation</b>

len = strlen( p1 ).

<i>* len = 4.</i>

off_set = 6 - len.

  • offset = 2.

if off_set <> 0.

CONCATENATE dummy(off_set) p1 into p1.

endif.

<i>* p1 = 002900.</i>

CONCATENATE p1(2) ':' into p2.

<i>* p2 = 00:2900.</i>

CONCATENATE p1+3(2) ':' into p2.

<i>* p2 = 00:29:00.</i>

Message was edited by:

vickram s

5 REPLIES 5
Read only

Former Member
0 Likes
561

data p1(6) type c value '2900'.

data p2(8) type c.

data len type i.

datat off_set type i.

data dummy(6) type c value '0000'.

<b>* operation</b>

len = strlen( p1 ).

<i>* len = 4.</i>

off_set = 6 - len.

  • offset = 2.

if off_set <> 0.

CONCATENATE dummy(off_set) p1 into p1.

endif.

<i>* p1 = 002900.</i>

CONCATENATE p1(2) ':' into p2.

<i>* p2 = 00:2900.</i>

CONCATENATE p1+3(2) ':' into p2.

<i>* p2 = 00:29:00.</i>

Message was edited by:

vickram s

Read only

Former Member
0 Likes
560

hi Alex,

I am giving a psuedo code. u might need to do adjustment for syntax etc.

1) l_time has 2900.

2) take l_time in string format l_time_str

3) length = length( l_time_str ) - 2.

4) l_seconds = l_time_str+length(2).

5) length = length - 2.

6) l_minutes = l_time_str+length(2).

So on. need to put If condition for length >= 0.

Regards,

Vivek.

Read only

Former Member
0 Likes
560

Hi Alex,

try this

data x type t value '002900'.

write (8) x using edit mask '__:__:__'.

regards,

pankaj singhreward points if problem is solved

Read only

Former Member
0 Likes
560

<b>* declaration part</b>

data p1(6) type c value '2900'.

data p2(8) type c.

data len type i.

datat off_set type i.

data dummy(6) type c value '0000'.

<b>

  • converting 2900 to 00:29:00.</b>

len = strlen( p1 ).

<i>* len = 4.</i>

off_set = 6 - len.

<i>* offset = 2.</i>

if off_set <> 0.

CONCATENATE dummy(off_set) p1 into p1.

endif.

<i>* p1 = 002900.</i>

CONCATENATE p1(2) ':' into p2.

<i>* p2 = 00:2900.</i>

CONCATENATE p1+3(2) ':' into p2.

<i>* p2 = 00:29:00.</i>

write: p2.

Read only

Former Member
0 Likes
560

try this.

data : pdat(6) type n value '2900'.

data : phr(2),

pmin(2),

psec(2),

ptime(8).

phr = pdat(2).

pmin = pdat+2(2).

psec = pdat+4(2).

concatenate phr pmin psec into ptime separated by ':'.

regards

shiba dutta