Looping fields

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
hcdiss
Participant
Posts: 26
Joined: Sat Oct 14, 2006 1:45 am
Location: Boston

Looping fields

Post by hcdiss »

my i/p is in following format... :

ID | KEY | DIV

111 | 123 | G
111 | 345 | E
111 | 456 | E
111 | 323 | E

I just require some guidance for this piece of input and rest i can work around

the o/p transformation rule is --> for the same ID map the E key to G key

so o/p should be

ID | KEY | DIV

111 | 123 | G
111 | 123 | E
111 | 123 | E
111 | 123 | E

I have used stage variables for the same.

preID --- currID
preKEY -- currKEY
currID -- id
currKEY -- key

I get the o/p as desired but only for the 1st E customer.For rest E Customer KEY remains as it is.
i dont understand how to make it valid for all E customers.How do i loop this??

curr o/p what i am getting is --->

ID | KEY | DIV

111 | 123 | G
111 | 123 | E
111 | 456 | E
111 | 323 | E


II have also thought of using sort and then using keychange column...but first wanted to know if there can be some solution to this.
hcdiss
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

currKey = (if div = "G" then key else currKey)

Note - this is left partial assuming you will always have a G for each ID.
Post Reply