09-27-2007 6:43 PM
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
09-27-2007 6:47 PM
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.
09-27-2007 6:47 PM
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.
09-27-2007 6:47 PM
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.
09-27-2007 6:49 PM
09-27-2007 7:02 PM
Hi,
U try this,
<b>Data : L_5(5) value '1234'.
translate l_5 using ' 0'.
write : l_5.</b>
Regards,
Padmam.
09-27-2007 9:10 PM
Thanks Sri, Kevin, Puneeth.
I gave points to all of you.
I used Kevin's overlay keyword and it worked.
Thanks again.
Regards,
Balu