Using @Iteration Loop Condition

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
ScottDun
Participant
Posts: 61
Joined: Thu Dec 10, 2015 9:51 am

Using @Iteration Loop Condition

Post by ScottDun »

Hi,

I am creating a job in which I need to use an iteration. The job I have has a seq. file with one row of data, two transformers and im mapping to a table using db2 connector. In the first transformer, I have the columns mapped to what the table looks like. The second transformer will have a loop iteration I am thinking.

There is a field that will be populated and in the first transformer I am leaving it as spaces. Three columns from the seq file will be used to populate the the field that I put to spaces but depending on what happens to the three columns. Column A will be populated with number sets that are colon separated (ex 111:222:333), Column B will be '159' or spaces (If Y then 159 else 0) and Column C will be '158' or spaces.

The Iteration should be used to populate the one field (that is presently set to spaces in transformer 1) in transformer 2. My iteration is if Iteration =1 then column A Else If iteration 2 then column B Else Column C. However, if B is spaces, then I want to eliminate that from populating; same goes for C.

So I need a minimum of Column A to be populated and then have each number that is colon separated to have their own row (ex 111:222:333 needs to be 111 then another row with 222 etc). If Column B has 159 then it gets populated and if Column C has 158 it gets populated. If B or C or both have spaces, then they do not get populated.

I need a little help with the Iteration statement, so any and all help is very much appreciated.

Thanks
SCOTTDun
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Do B and C get populated in all three rows in your example?

Your need to iterate through a delimited list is one of the examples in the documentation, almost exactly. Count the number of delimited fields into a stage variable, say svItemCount, then your loop exit condition is

Code: Select all

@ITERATION <= svItemCount
Within the loop, use a Field() function to extract the particular value:

Code: Select all

Field(InLink.A, ":", @ITERATION, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ScottDun
Participant
Posts: 61
Joined: Thu Dec 10, 2015 9:51 am

Post by ScottDun »

B and C need only to be populated if they have a value of 159 and 158, respectively. If B doesn't have 159, then it will not be included; same goes for C.
SCOTTDun
Post Reply