Application Development 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: 

Leading zeroes disappearing in time

suryakumar1223
Explorer
0 Kudos
144

Hello,

I have one variable for the gv_time.

Here,

gv_time = 05:04:02

here I seperated it into 3 variables

As gv_hour = gv_time(2)

gv_min = gv_time+3(2)

gv_sec = gv_time+6(2)

here I need to add 1 sec to gv_sec ...

When I use this code :

gv_sec = gv_sec + 01.

Then gv_sec = 3

But I need it as '03'.

Finally requirement is I need preceding zero in sec .

2 REPLIES 2

j_pavan_kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos
101

Hi,

You can have a data type of NUMC length 2 for gv_sec and that will take care of preceding zero.

or

You can have a conversion exit if gv_sec is of CHAR type.

DATA(lv_sec) = |{ gv_sec ALPHA = IN }|

P.S - I am not sure about the business requirement you are having but technically it is wrong to increment second by 1 separately as it will have side effects on hours and minutes once it reaches to 60 secs. Instead try keeping the time(hh:mm:ss) in sy-uzeit type then increment it by 1.

Sandra_Rossi
Active Contributor
0 Kudos
101

I don't understand what you mainly want to achieve.

DATA(gv_time) = CONV t( '050402' ).
DATA(gv_time2) = CONV t( gv_time + 1 ). " + 1 second
ASSERT gv_time2 = '050403'. " NOT NEEDED, just for your information

gv_time = '050459'.
gv_time2 = gv_time + 1. " + 1 second
ASSERT gv_time2 = '050500'. " NOT NEEDED, just for your information