Looping Activity in DataStage

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
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Looping Activity in DataStage

Post by krisp321 »

Hi
I have a requirement as below


File1--->some stages---->Transformer
---->File3
---->File2



Transformer pushes data into File2 and File3

Now File3 need to become the source file File1
Again same job runs
This process should keep on going until the count in File3 becomes zero
and File2 data keeps on appending during this process

Say for example,
I have 5 records in File1 now the job starts
3 records got loaded in File3
and 2 records in File2

Now 3 records in File3 should become the source now as File1
now let us say
1 got written in File3
and 2 appended(total 4) in file2

Now 1 records in File3 should become the source now as File1
now let us say
0 got written in File3
1 got appended in File2
Now the loop should break as there are no more records for further processing in File3


I thought of using startloop and endloop activity in Sequence job but looking for any better idea.

Any suggestion is greatly appreciated

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

Post by ray.wurlod »

StartLoop and EndLoop activities in sequence seems to me to be the best approach.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Post by krisp321 »

ray.wurlod wrote:StartLoop and EndLoop activities in sequence seems to me to be the best approach. ...
Hi
Could you please suggest me how to handle it in Sequence using start loop and end loop

Thanks
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

you can use 'comma,semicolon or any other delimeter' to specify the count of loop dynamically

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

Post by chulett »

Seems to me you'll need to set a high threshold on the loop (since you can't know when it will end) and then specifically exit the loop when your condition is met.
-craig

"You can never have too many knives" -- Logan Nine Fingers
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Post by krisp321 »

Hi

Yes you are right. I was thinking how to handle this loop end. Any suggestions from your end please

At job level, everytime I am capturing re_process file counts in a diff file
at /temp/count.txt

In Sequence level using
Execute_Cmd_Acty(read count from file)
cat /temp/count.txt

UserVariable_Activity
If Execute_Cmd_Acty.$ReturnValue > 0 Then StartLoop.$Counter Else DSJS.STOPPED

Some where I am not able to do it in right way, still loop is running

In startloop, Under loop definition
I used values
1
1
5
( I know I am doing wrong here in start loop)
Any suggestion is greatly appreciated

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

Post by chulett »

There's no "else" to stopping. From your Execute Command stage, link a zero trigger to a stage after the End Loop. The >0 trigger goes to the End Loop stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
krisp321
Participant
Posts: 39
Joined: Thu Mar 04, 2010 12:39 am

Post by krisp321 »

chulett wrote:There's no "else" to stopping. From your Execute Command stage, link a zero trigger to a stage after the End Loop. The >0 trigger goes to the End Loop stage. ...
Hi
Can you please tell me in a little more eloborative way which may help me more.
I couldnt get anything from your above sentense

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

Post by ray.wurlod »

Code: Select all

---> StartLoop  <---------------------  EndLoop
           |                                ^
           |                                |
           V                                |
       DoStuff  -------->  Test  -----------+
                             |          >0
                             | = 0
                             V
                         DoNothing
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And that "DoNothing" exit from the loop can be a Sequencer if you just want to stub it out or another string of stages if you need to do something afterwards - send an email, run more jobs, etc.
-craig

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