Fill the remaining spaces

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
cherry
Participant
Posts: 108
Joined: Sun Jul 10, 2005 1:35 am

Fill the remaining spaces

Post by cherry »

Hi All,

I have a field that has its length as Char(10), for this field if it has the data length that is coming in is 7 characters and the remaing space it has to get filled with the values AAA

Could you please tell me how can we achieve this.

Thanks in advance

Best Regards
Cherry
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

A Char(10) field cannot have 7 characters. This will only work if your source field is defined as CHAR(7), in which case your derivation will be "In.Char7Field:'AAA'".
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Maybe the o/p is saying that input is char(10) of which it has 7 non-blank chars and 3 blank chars (which is to be replaced by 'AAA')

Something like

Code: Select all

inputField[1, 7] : 'AAA' 
Obuli
Participant
Posts: 4
Joined: Fri Jul 17, 2009 1:45 pm
Location: Chennai

Re: Fill the remaining spaces

Post by Obuli »

Why not you try "PadString" function
algfr
Participant
Posts: 106
Joined: Fri Sep 09, 2005 7:42 am

Post by algfr »

PadString with 'A' as the pattern and 3 as the length I'd say
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A more general solution would have regard for the length of the inbound string. I'd use something like

Code: Select all

Left(InLink.TheString : Str("A",10), 10)
If InLink.TheString is likely to contain more than ten characters this expression will return only the leftmost 10 of them. If this is not the requirement, please adapt the expression to suit.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply