How to solve below scenario using loop in tfm or otherway

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
seanirs
Participant
Posts: 3
Joined: Fri Dec 29, 2017 12:31 pm

How to solve below scenario using loop in tfm or otherway

Post by seanirs »

My data is like below in one column coming from a file. There is customer information and every customer can have one meter or many meters and every meter will have atleast one reading or many. every meter may or may not have a meter statement. if meter statement is absent then pad 100 spaces. below is the sample data. there is only one column in the complete file and no other columns and no other way to tie to those meters and readings to the parent customer. just follow the order in sequence.

Source_data---(This is column name)
CUSTOMER 15
METER 8
METERStatement 1
READING 1
METER 56
Meterstatement 17
Reading 5
Reading 6
Reading 7
CUSTOMER 38
METER 24
METERStatement 1
READING 51
CUSTOMER 77
METER 38
READING 9

I want the output data to be like below in one column

CUSTOMER 15 METER 8 METERStatement 1 READING 1
CUSTOMER 15 METER 56 Meterstatement 17 Reading 5
CUSTOMER 15 METER 56 Meterstatement 17 Reading 6
CUSTOMER 15 METER 56 Meterstatement 17 Reading 7
CUSTOMER 38 METER 24 Meterstatement 1 Reading 51
CUSTOMER 77 METER 38 'pad 100 spaces' Reading 9

I am trying to solve by reading transformer looping documentation but could not figure out an actual solution. anything helps. thank you all.
Last edited by seanirs on Fri Dec 29, 2017 1:38 pm, edited 1 time in total.
sean
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

I don't see any need for transformer looping. It looks to me like you can do everything with stage variables and output constraints.

Mike
seanirs
Participant
Posts: 3
Joined: Fri Dec 29, 2017 12:31 pm

Post by seanirs »

could you please elaborate for me...
sean
seanirs
Participant
Posts: 3
Joined: Fri Dec 29, 2017 12:31 pm

Post by seanirs »

There is customer information and every customer can have one meter or many meters and every meter will have atleast one reading or many. every meter may or may not have a meter statement. if meter statement is absent then pad 100 spaces. below is the sample data. there is only one column in the complete file and no other columns and no other way to tie to those meters and readings to the parent customer. just follow the order in sequence
sean
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I, too, would resolve this purely using stage variables. You need an output link constraint expression to determine when to generate an output row (e.g. when the input is a READING row).
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