any function to right justify the values in a column

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
srekant
Premium Member
Premium Member
Posts: 85
Joined: Wed Jan 19, 2005 6:52 am
Location: Detroit

any function to right justify the values in a column

Post by srekant »

i am new to datastage.currently i am working on datastage 7.5 PXjobs. I want to right justify the data that is going to target in the transformer.is there any function to do it.
Sree
NewPXUser
Participant
Posts: 17
Joined: Fri Feb 11, 2005 6:06 am

Post by NewPXUser »

From my experience (which is simple and straight-forward), try using stage variables in the way mentioned below.

TrimStr <- Trim(YourLinkVariable)
LengthStr <- Len(TrimStr)
SpaceStr <- Space(50 - LengthStr)

// where 50 is the length of the field. Change if different

YourOutputColumn <- SpaceStr : TrimStr

It worked for me and so I believe it will work for you too.

I tried using -ve value in PadString length but in vain. So if anyone has better idea, please let me know.
srekant
Premium Member
Premium Member
Posts: 85
Joined: Wed Jan 19, 2005 6:52 am
Location: Detroit

Post by srekant »

thanks for u r reply

but can u explain ur last step when writing to an output column

cheers
Sree
NewPXUser
Participant
Posts: 17
Joined: Fri Feb 11, 2005 6:06 am

Post by NewPXUser »

The derivation of writing to the output (link) column is

SpaceStr : TrimStr

Does that answer your question or was it different?
chalasaniamith
Participant
Posts: 36
Joined: Wed Feb 16, 2005 5:20 pm
Location: IL

Hi NewPXUser

Post by chalasaniamith »

Hi

I am very new so dont think wrong is this available function TrimStr i think its just
Trim(String) not TrimStr.
Please let me know if i am wrong.
I will correct for myself
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

As per the steps mentioned, TrimStr is a 'stage variable' obtained as the result of Trim() function. See the mail from NewPXUser.
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

Left(Space(maxsizeofstring) : actualstring, maxsizeofString)
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Or maybe it must be

RIGHT(Space(maxsizeofstring) : TRIM(actualstring), maxsizeofString)
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

Oops.

Yeah.

Right() is correct. :oops:
Post Reply