2022 Dec 07 11:28 AM
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 .
2022 Dec 07 1:34 PM
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.
2022 Dec 07 3:10 PM
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