Page 1 of 1

Append Leading Zeros

Posted: Wed Jun 13, 2012 12:03 pm
by pavan_test
Hi all,

The output column length has to be 8 bytes. If the data in the incoming column (say xyz) is less than 8 bytes then I have to append leading zeros (to make to equal to 8 bytes) before writing the output file.

can someone please let me know how can achieve this in datastage.

Thanks
pavan

Posted: Wed Jun 13, 2012 1:18 pm
by chulett
You need to emulate an lpad and ensure your target is a string.

Re: Append Leading Zeros

Posted: Wed Jun 13, 2012 1:22 pm
by rprajput
Use the Str function for the derivation of the output column as -

Str("0", 8 - Len(inputcolumn)) : inputcolumn

Posted: Wed Jun 13, 2012 2:46 pm
by jwiles
Or even simpler and generally less expensive (assuming your input is either string or integer):

right("00000000" : inputcolumn,8)

Regards,

Posted: Wed Jun 13, 2012 2:51 pm
by chulett
Both of which are in the post I linked to. :wink: