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: 

Tailing Zero Adding

Former Member
0 Kudos

Hello Gurus.

I have declared a field (L_5) with type C and length 5.

If the legth of L_5 is less than 5, Suppose I have the value L_5 = '1234'. I need to make this value as 5 character length with tailing zeroes.I.e L_5 = '12340'.

Is there any functional module to do this.

Or any other ideas?

Regards,

Balu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Balu,

You can use the Strlen function to find out the string length.

If the string length is less than 5,then concatenate the number of zeroes to the stri ng and display.

You can concatenate the number of zeroes by checking it in Case statements.

When string length is 2.

Case.

When '2'.

Concatenate '000' to string.

likewise...................

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.

5 REPLIES 5

Former Member
0 Kudos

Hi Balu,

You can use the Strlen function to find out the string length.

If the string length is less than 5,then concatenate the number of zeroes to the stri ng and display.

You can concatenate the number of zeroes by checking it in Case statements.

When string length is 2.

Case.

When '2'.

Concatenate '000' to string.

likewise...................

In case you have any further clarifications,do let me know.

Regards,

Puneet Jhari.

Former Member
0 Kudos

Try this:

len = strlen( v2 ). <<check the length, if it is less than 5 digits,

then append the reqd. no. of zeroes at the end>>

len2 = 5 - len.

do len2 times.

concatenate v2 '0' into v2.

enddo.

write:/ v2.

Former Member
0 Kudos

overlay l_5 with '00000' only space.

Former Member
0 Kudos

Hi,

U try this,

<b>Data : L_5(5) value '1234'.

translate l_5 using ' 0'.

write : l_5.</b>

Regards,

Padmam.

0 Kudos

Thanks Sri, Kevin, Puneeth.

I gave points to all of you.

I used Kevin's overlay keyword and it worked.

Thanks again.

Regards,

Balu