Shifting and Truncating

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
chakkara
Participant
Posts: 5
Joined: Thu Jun 28, 2018 7:05 pm

Shifting and Truncating

Post by chakkara »

Hi folks,

I have an input file which has 5 digit chars.

My requirement is to pad a character at the left most position and truncate the right most one. kindly suggest how to achieve this

Ex :

Input

1,ABCDE

Output:

1,SABCD
1,SSABC
1,SSSAB
1,SSSSA
1,SSSSS
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What have you tried so far, anything? Seems to me a combination of transformer looping, substring via 'left' and simple concatenation would do the trick. Lather, rinse, repeat.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I agree with Craig. Try it, and let is know how you go. Assuming you are using a counted loop, loop while @ITERATION <= 5
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
UCDI
Premium Member
Premium Member
Posts: 383
Joined: Mon Mar 21, 2016 2:00 pm

Post by UCDI »

a mix of substring operations should get you there, eg
newvalue = left(oldvalue, 2):'S':right(oldvalue,4)
newvalue2 = left(oldvalue, 2):'SS':right(oldvalue,3)
..etc

do that in a stage variable is one way, eg if you wanted each value in a new column.

use a loop if you wanted each one as a new record.
Post Reply