‎2008 Jul 21 5:39 PM
hi guys,
i need to fill a field with left 0s.
example.
data: num(10).
data: len type p,
data: n type n.
num = '12345'. " and i want '0000012345'
describe field num into len.
n = 10 - len.
shift num right by n places.
do n times.
replace space with '0' into num
enddo.
this will work, my problem is that describe field always give 10, and i need exactly the number of positions filled.
any ideas?
tks in advance
‎2008 Jul 21 5:40 PM
hi,
you can use STRLEN for determining the actual length of the string.
length = STRLEN( string ).
You can also use conversion exit for this: FM CONVERSION_EXIT_ALPHA_INPUT will fill the string with leading zeros (irrelevant how much you actually need)
hope this helps
ec
‎2008 Jul 21 5:40 PM
hi,
you can use STRLEN for determining the actual length of the string.
length = STRLEN( string ).
You can also use conversion exit for this: FM CONVERSION_EXIT_ALPHA_INPUT will fill the string with leading zeros (irrelevant how much you actually need)
hope this helps
ec
‎2008 Jul 21 5:42 PM
Hello,
Define a character field of length 10.
Move the value of num field to this character field.
Pass this character field to the function module 'CONVERSION_EXIT_ALPHA_INPUT'
this will give you a 10 character string with the leading zeroes.
cheers,
Sushil Joshi
‎2008 Jul 21 5:55 PM
Hi Javier,
Try the following.
data:
w_strln type i,
w_str1(10) type n,
w_places type i.
w_strln = strlen(w_str).
w_places = 10 - w_strln.
do w_places times.
concatenate '0' w_str into w_str1.
enddo.
Hope this helps you.
Regards,
Chandra Sekhar