Looping

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

DS1
Charter Member
Charter Member
Posts: 29
Joined: Wed Mar 29, 2006 1:13 pm

Looping

Post by DS1 »

Hello everyone,

I am working on PX 7.1 and need to create a loop to calculate data for one month and then using that data to calulate data for previous month and so forth , thus create a loop such that if in Dec - it should calculate data for 11 times.
eg - using May data to get april data, using that derived april data to get jan march data and then with that derived march data get feb data.

please help me know what are the ways to do recursive actions

Thanks

DS1
thebird
Participant
Posts: 254
Joined: Thu Jan 06, 2005 12:11 am
Location: India
Contact:

Post by thebird »

Correct me if I am wrong -

From your example - you have May data as the source. You want to process this and come up with the data for April. Then using April's data you want to come up with March data - is that correct?

You can run your Job in a Loop from the job sequence. StartLoop and EndLoop may be two activities that you might want to look at.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It doesn't need to be recursive. Use a simple counted loop from month number down to 1, perhaps in a Start Loop activity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Hi,

You need to use the start Loop and end loop features in a routine. I think
the DS Gurus are referring to using a routine to achieve this.

Regards
Sreeni
thebird
Participant
Posts: 254
Joined: Thu Jan 06, 2005 12:11 am
Location: India
Contact:

Post by thebird »

Sreenivasulu wrote: You need to use the start Loop and end loop features in a routine. I think
the DS Gurus are referring to using a routine to achieve this.
Why would you go for creating a routine, when the same can be achieved easily through the Start Loop and End Loop Activities in the Sequence?
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

HI

I dont think its a good design to use a loop feature in sequencer to loop for each record. Looping in sequencer is generally used to loop to
different subprocesses not to work on on record in a loop.

Regards
Sreeni

quote="thebird"]
Sreenivasulu wrote: You need to use the start Loop and end loop features in a routine. I think
the DS Gurus are referring to using a routine to achieve this.
Why would you go for creating a routine, when the same can be achieved easily through the Start Loop and End Loop Activities in the Sequence?[/quote]
thebird
Participant
Posts: 254
Joined: Thu Jan 06, 2005 12:11 am
Location: India
Contact:

Post by thebird »

Sreenivasulu wrote:
I dont think its a good design to use a loop feature in sequencer to loop for each record. Looping in sequencer is generally used to loop to
different subprocesses not to work on on record in a loop.
Sreeni,

We are not talking about looping through records but a single job being run in a loop.
The requirement here I believe is to run a job multiple times with different set of data each time - the input file for the job being created by the job itself in the previous run (except for the first run ofrcourse).

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

Post by Sreenivasulu »

We can check about the exact requirment with the guy who posted this message

Regards
Sreeni
DS1
Charter Member
Charter Member
Posts: 29
Joined: Wed Mar 29, 2006 1:13 pm

Post by DS1 »

Thanks all of you for replying and helping.

thebird is correct-
''The requirement here I believe is to run a job multiple times with different set of data each time - the input file for the job being created by the job itself in the previous run (except for the first run ofrcourse). '' -

I will research more about start-loop and end-loop stages in sequence.

Please let me know about any specific things that i need to consider or keep in mind while using these stages.

Thanks

DS1
DS1
Charter Member
Charter Member
Posts: 29
Joined: Wed Mar 29, 2006 1:13 pm

Post by DS1 »

i donot see - startloop and end loop in 7.1 - I guess they are in 7.5?

7.1 is really basic at sequence.

so now what can be done in 7.1

Thanks

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

Post by chulett »

You get to write everything yourself!
-craig

"You can never have too many knives" -- Logan Nine Fingers
jgreve
Premium Member
Premium Member
Posts: 107
Joined: Mon Sep 25, 2006 4:25 pm

plz elaborate on algorithm & bus rules

Post by jgreve »

DS1 wrote:create a loop to calculate data for one month and then using that data to calulate data for previous month and so forth , thus create a loop such that if in Dec - it should calculate data for 11 times.
eg - using May data to get april data, using that derived april data to get jan march data and then with that derived march data get feb data.
Is your raw data living in a database? dataset? flat files?
If it is in a database, there's a good chance you could make a custom query that would do what you need and use that as a datasource.

Am I following your example correctly?

Code: Select all

may = deriveData("may", null ).
april = deriveData( "april", may);
march = deriveData( "march", april );
feb = deriveData("feb", march );
What does the deriveData function do? compute a single numeric value for slaes, for example? or is it more like a vector? or record set? or...?
Why doesn't may need a 'starting' value ?
John G.
DS1
Charter Member
Charter Member
Posts: 29
Joined: Wed Mar 29, 2006 1:13 pm

Post by DS1 »

I am working on 7.1 and the sequencer doesnot have start-loop and end-loop ..

please advise
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

As Craig advised, you can write your own loop. All you need to do is put your DSRunJob command within a loop that counts backwards untill it hits Jan. That is simple looping data structure.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You get to write everything yourself!

You can use job control code, or you can use a Routine activity calling UtilityRunJob().
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