Loops in Datastage jobs/sequences

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

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

Post by ray.wurlod »

Recursion of job execution is not possible in DataStage. A particular instance of a job can only be started if it is in a runnable state, and "running" is not a runnable stage.

Iteration, on the other hand, is very straightforward. Note, though, that there is no tool in the graphical job sequencer palette for achieving it.

You have essentially two ways that you can go.

You can modify the job control code that is produced by the sequencer or a batch, or write your own, that opens the directory where the files reside (use the OpenPath statement) and loops through the file name values, starting a child job to process each file. The child job can be run using DSRunJob() after setting appropriate parameters.

Alternately you could create a job that processed the directory as if it were a table, providing a stream of file names, and invoking the sdk function UtilityRunJob().
nigel
Premium Member
Premium Member
Posts: 35
Joined: Tue May 07, 2002 2:48 am
Location: South Africa/UK
Contact:

Post by nigel »

Hi Guys,

What about write some code that does the following:

Creates a file pointer entry in the VOC with a type "F", data location of the directory name, dictionary pointing to the same path as the dictionary of the "&UFD&" file.
This will make datastage see the direcory as a Type 1 file.
The files in the directory can then be termed as records.
You can then select all the records to a numbered select list (the key to each "record" being the filename).
Then use the READLIST command to put the keys read from the select list into a dynamic array.
Then process each key/filename with an iteration (FOR/NEXT, LOOP/REMOVE/REPEAT).

All your other methods mentioned work well, just thought I'd give another one.

Regards

Nigel Freddy

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

Post by ray.wurlod »

Nigel,
OpenPath gives you all that without having to muck about in the VOC file.
Regards,
Ray
Post Reply