counter Increment in a 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
deps1972
Premium Member
Premium Member
Posts: 12
Joined: Thu Sep 16, 2010 10:42 pm

counter Increment in a loop

Post by deps1972 »

Hi

I have created a job sequence in this flow
ExcecuteCommand --->StartLoop--->UserVariableActivity--->Jobactivity--EndLoop

I am doing a cat in ExcecuteCommand to get the content of a txt file which looks like this
ABN,Acct_BfwdData,Acct_CGTList,Acct_DiffList
I am looping around this file with a comma delimeter in start loop
In Uers Variable I am doing this to get a word for each iteration
Tabel_Name=Field(Execute_Command_0.$CommandOutput ,",", StartLoop_Activity_1.$Counter)
In the job activity I am passing this table name to a job in JOb activity like this Tabel_Name=UserVariables_Activity_25.Table_Name1

Problem I have is that for all 4 Iterations, table name is coming out same as ABN. What am I missing?
dj
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't recall the exact syntax off the top of my head but a search here should turn it up if you look for 'counter' I would think. From what I recall you need to index into the list of parameters using the counter and you usually create a delmited list all at once for the StartLoop stage to iterate the through. Then something like...

Code: Select all

Table_Name=UserVariables_Activity_25.Table_Name<$Counter>
Let me see if I can turn up an example.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This should help with the $Counter question, there are plenty of others out there if you search:

viewtopic.php?t=111013

This one might help as well:

viewtopic.php?t=127425
-craig

"You can never have too many knives" -- Logan Nine Fingers
deps1972
Premium Member
Premium Member
Posts: 12
Joined: Thu Sep 16, 2010 10:42 pm

Post by deps1972 »

chulett wrote:I don't recall the exact syntax off the top of my head but a search here should turn it up if you look for 'counter' I would think. From what I recall you need to index into the list of parameters using the counter and you usually create a delmited list all at once for the StartLoop stage to iterate the through. Then something like...

Code: Select all

Table_Name=UserVariables_Activity_25.Table_Name<$Counter>
Let me see if I can turn up an example.
Is this what you are suggesting Craig
This I did in my UserVariable Activity Stage
Trim(EReplace(Field(Execute_Command_0.$CommandOutput ,",", StartLoop_Activity_1.$Counter),@FM, ' '))
dj
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm not really suggesting anything, just trying to point you to posts which talk about loops and how to handle the counter properly so you could figure out your next steps on your own. Did you check them out? In the meantime...

I'm a little lost on what you are trying to accomplish with the UserVariables stage. Is there a single record in the file your Execute Command stage cats? And that is your "Comma-delimited List of Things" to iterate through? Assuming yes, you would loop four times and each time pass a single entry to the Job Activity with the following values?

1. ABN
2. Acct_BfwdData
3. Acct_CGTList
4. Acct_DiffList

Yes? If so then you don't need the UserVariables stage. The StartLoop already has this list so just skip the UV stage and use the following syntax in your Job Activity's parameter:

StartLoop_Activity_1.$Counter

If your loop list is in fact something else or I'm not understanding what you need to do, please enlighten us with many details and we'll continue on with this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
deps1972
Premium Member
Premium Member
Posts: 12
Joined: Thu Sep 16, 2010 10:42 pm

Post by deps1972 »

I had checked the links you suggested. You have understood it correctly. I am totally new to datastage and trying to figure out how it works. Your suggestion worked. Thanks for your help
dj
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