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

adding zeros addition

Former Member
0 Likes
785

Hi All,

there is a variable with length 2,

if variable having single charcter value like '1' need to make the variable value '02'

how to check the variable length and add the zero if variable having only one character.

please help me

regards

krishna

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
754

Hi Krishna

Use convert_exit_alpah_input FM to add zeros..

else

use lv_len = strln(variable).

lv_len will have the number 1 or 2 in ur case.. based on it you can add zeros.

6 REPLIES 6
Read only

Former Member
0 Likes
754

Hi Krishna,

insted u can declare that variable of type n. If you have 1 means it will display as 01.

or.

since that variable is of type c, by using strlength we can find out the length of the variable.

regards,

DVNS

Read only

former_member156446
Active Contributor
0 Likes
755

Hi Krishna

Use convert_exit_alpah_input FM to add zeros..

else

use lv_len = strln(variable).

lv_len will have the number 1 or 2 in ur case.. based on it you can add zeros.

Read only

Former Member
0 Likes
754

Hi,

try the following code..

data : var type i,

var2(3) type n.

var = 2.

if var < 10.

var2 = var.

endif.

write /: var, var2.

var2 will ouput with leading zeros...

Regards,

Viji

Read only

Former Member
0 Likes
754

Hi,

use FM convert_exit_alpah_input . don't care about length.FM will take care.

L.Velu

Read only

Former Member
0 Likes
754

Hi,

Assign the value to a numeric field. It will automatically takes care of zeros.

Ex: x type char02,

y(2) type n.

x = '1'.

y = x.

Write: / y.

Read only

Former Member
0 Likes
754

hi

declare that variable as of type n