Start Loop passing just first row into the loop

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

Start Loop passing just first row into the loop

Post by UAUITSBI »

Hello,

I have a text file (pipe delimited) with 3 rows. I am combining these 3 rows with a ',' (comma) as delimiter via Execute Command Stage. I am passing the output of the execute command to the Start Loop to define delimited values.
Issue: When running the job, 3 iterations are performed as expected but only first row is being passed in all those 3 iterations. Not sure why start loop activity is not picking all 3 rows.

I designed a sequencer job as below:

Code: Select all

ExecuteCommand --> UserVariableActivity (to Trim @FM) --> StartLoopActivity (Defined output from UserVariableActivity) --> UserVariableActivity (To set values from the row to the columns in table) --> Parallel_Job --> End Loop Activity
Example: Three rows in the file:
Row1: AB|CD
Row2: EF|GH
Row3: IJ|KL

Single Row: AB|CD,EF|GH,IJ|KL

When passing the above row into the loop only AB|CD row is being processed 3 times.

Any help in this regards is much appreciated.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Are you leveraging $Counter when you pass the parameter from the loop to the Job Activity stage?
-craig

"You can never have too many knives" -- Logan Nine Fingers
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

Post by UAUITSBI »

@chulett -- Thanks for bringing that up. No I am not leveraging $Counter from start loop in the Job Activity. I am using User Variable Activity to set values for the parameters in the table (in job activity).

How can I leverage the $Counter in job activity when I am setting values for the parameters in the job activity from user variable activity ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How are you passing it now? It's been quite a while but from what I recall you should be able to simply add ".$Counter" to what you are doing now so that it iterates properly inside the loop. One sec...

There's an example here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

Post by UAUITSBI »

@chulett: I am currently using UserVariableActivity inside the loop to derive the parameters coming from a file and in the job activity stage I am assigning these values to the job parameters in the job activity.

I am including images:

Example: Parameter value of 'AB' (from text file) is been assigned 'Code' parameter in the job:

UserVariableActivity: Code: Field(Exec_Read_File.$CommandOutput, '|',1)
https://ibb.co/fNbHM8

Job Activity: For parameter name Code: UserVariableActivity.Code
https://ibb.co/hs8iTo

Loop Activity: https://ibb.co/iXau18

How can I leverage $Counter in the above scenario ?

Thanks for the help thus far.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'll have to check later, your image site is blocked here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

Post by UAUITSBI »

I will try with other image hosting site.

Job Activity:
https://imgur.com/gFsV786

User Variable Activity:
https://imgur.com/5RhoHkw

Loop Activity:
https://imgur.com/mDdXtwx


Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Okay. Don't you just need to set the UserVariables once, not each time through the loop? Typically, it would be before the Start Loop stage to set the delimited list it loops through. Can you show us the properties in the Start Loop stage itself, please?
-craig

"You can never have too many knives" -- Logan Nine Fingers
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

Post by UAUITSBI »

Yes that makes sense to use outside the loop. But still I need to map the UserActivity variables in the job activity to pass the parameters.

Below is the Start Loop Properties:

https://imgur.com/aykaFJk
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

Post by UAUITSBI »

I have moved the user variable activity to the outside of the loop but still just first row is getting looped all 3 times.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right, that will continue to happen until $Counter comes into play. Sadly, fighting my own fires right now. Did you look at the example from IBM I posted earlier, specifically Figure 5 on that page? Hopefully that helps.
-craig

"You can never have too many knives" -- Logan Nine Fingers
UAUITSBI
Premium Member
Premium Member
Posts: 117
Joined: Thu Aug 13, 2009 3:31 pm
Location: University of Arizona

Post by UAUITSBI »

@chulett: You are right! I have used Field($Counter,'|',1) in job activity and that picked up second and third row respectively.

Thanks for the help !
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply