We have moved to www.dataGenX.net, Keep Learning with us.

Monday, October 20, 2014

Create Fixed Width Data in DataStage


In day to day life of DataStage, you are facing lot of business scenario and technical scenario. Today, we are going to discuss how to generate Fixed Width data from variable length data in datastage.


Input :
23
3345
546576
535
80
2342


Output :
0000023
0003345
0546576
0000535
0000080
0002342



We can generate the Fixed width data in Transformer. We need to padd the zero or spaces before or after string as per our scenario. Here, for formatting the number in Fixed Width, we are padding the 'zero' at left of no.

Transformer Derivation :
Str('0', 7 - Len(Input)) : Input             (If Input is Number)
Str(' ', 7 - Len(Input)) : Input             (If Input is String)

What this derivation do ?

Len(Input) - This will give the no of char present in string.
Len(3345) = 4
Str('0', 7 - Len(Input))  ==>  Str('0',3)  ==> 000
Str('0', 7 - Len(Input)):Input  ==> 0003345



Like the Facebook Page & join Group
https://www.facebook.com/DataStage4you
https://www.facebook.com/groups/DataStage4you

https://twitter.com/datastage4you
For WHATSAPP group , drop a msg to 91-88-00-906098



No comments :

Post a Comment