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,

Please can any one help me .

i have one field <b>char 6</b> ,i need to add zeros to this field.

ex:1) field value is 1 i need to do like 000001.

2) field value is 20 i need to make it 000020.

kindly give me solution for this.

Thanks in Advance .

Thanks & Regards.

Ramu.

9 REPLIES 9

Former Member
0 Kudos

Can you just define a variable of type n with the same length and initialise the value into it.

lnum(6) type n.

lnum = lfield1.

lnum would have the value with leading zeroes,

OR you can use the below.

llen = 6 - strlen(lfield1).

concatenate lfield1 '000000' into lfield1.

shift lfield1 circular by llen places.

Message was edited by: Anurag Bankley

Former Member
0 Kudos

use the command unpack.

or

use fm conversion_exit_alpha_input

santhosh

Former Member
0 Kudos

hi,

use the FM CONVERSION_EXIT_ALPHA_INPUT

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = var1

importing

output = var1.

hope this helps,

do reward if it helps,

Priya.

0 Kudos

use the FM CONVERSION_EXIT_ALPHA_INPUT

Regards

- Gopi

Former Member
0 Kudos

hi

use FM

CONVERSION_EXIT_ALPHA_output for display and

CONVERSION_EXIT_ALPHA_input for input

regs

Manas Ranjan Panda

Former Member
0 Kudos

hi

good

CONVERSION_EXIT_ALPHA_INPUT converts any number into a string fill with zeroes, with the number at the extreme right

Example:

input = 123

output = 0000000000000...000000000000123

thanks

mrutyun^

Former Member
0 Kudos

hi,

just use this ..

data : val like  lips-posnr  value '20'.

write:/ val.

regards,

vijay

Former Member
0 Kudos

Hi,

use the function module:

<b>CONVERSION_EXIT_ALPHA_INPUT</b>

converts any number into a string fill with zeroes, with the number at the extreme right

Example:

input = 123

output = 0000000000000...000000000000123

Hope it helps.

reward if helpful.

Regards,

Sipra

former_member184495
Active Contributor
0 Kudos

hi Ramu,

you could do the following.

-


data: c1(6) type c.

data: d1(6) type n.

c1 = '10'.

d1 = c1.

-


now d1 would have value 000010

cheers,

Aditya.