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: 

Add leading Zeros

Former Member
0 Kudos

Hi all,

I want to add leading zeros for a number which is of type character.

For example

Data : w_lan type char12.

w_lan = 4030.00

i want this to be w_lan = 000004030.00

The function modules CONVERSION_EXIT_ALPHA_OUTPUT and CONVERSION_EXIT_ALPHA_INPUT wont work in this case. Suggest some other way .

Regards,

Radha.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hiiii....

calculate the string length and loop it and concatenate 0 and the number untill u get the desired status .....

l = strlen(w_lan).

v = 0.

while l < 10.

concatenate v to l into target.

endwhile.

now the value will be stored in the target.

reagrds .

chandu reddy.

8 REPLIES 8

former_member195383
Active Contributor
0 Kudos

declare ......

co_zeros type char5 value '00000'.

concatenate co_zeros wf_lan into wf_lan.

Reward points...if its useful...

Regards

Rudra

prasanth_kasturi
Active Contributor
0 Kudos

hi,

Pass it to numeric variable of same length

Data : w_lan type char12.

w_lan = '4030.00'.

data : v_numc(5) type n.

CONCATENATE v_numc w_lan into w_lan.

write w_lan.

Former Member
0 Kudos

dear friend,

problem can be solve like this:

take one variable assign the value like this : v_zero = '0000'.

now concatinate this v_zero to our desire variable,

and now pass the total to a new variable v_new.

your problem will solve.

rewards are expecting

vivek

Former Member
0 Kudos

hiii

without using CONVERSION_EXIT_ALPHA_INPUT FM you will not achieve this.that CONVERSION_EXIT_ALPHA_INPUT can be use here but for that you need to convert w_lan type char12. to w_lan1(12) type n.then use CONVERSION_EXIT_ALPHA_INPUT FM & then you can convert this value in to w_len.it will defenetly solve your problem.

Data : w_lan type char12.

Data : w_lan1(12) type n.

w_lan = 4030.00.

w_lan1 = w_lan.

here use CONVERSION_EXIT_ALPHA_INPUT FM.

reward if useful

thx

twinkal

Former Member
0 Kudos

Hi ,

In the field catalog of that field.

Give

fld_cat-lzero = 'X'.

Reward if useful.

Regards,

Talwinder

Former Member
0 Kudos

Friends every time it is not '0000' , in some cases 3 and some cases 5

0 Kudos

write the logic as :

Data : w_lan type char12.

data : w_num(12) type n.

w_lan = '4030.00'.

w_num = w_lan. <-- move to numeric field

w_num = w_num / 100.

w_lan = w_num. <-- again move to char field.

write 😕 w_lan.

Former Member
0 Kudos

Hiiii....

calculate the string length and loop it and concatenate 0 and the number untill u get the desired status .....

l = strlen(w_lan).

v = 0.

while l < 10.

concatenate v to l into target.

endwhile.

now the value will be stored in the target.

reagrds .

chandu reddy.