Start Loop Activity Stage - want to source a parmfile.txt

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
lpadrta
Premium Member
Premium Member
Posts: 38
Joined: Thu Nov 07, 2002 7:39 am
Location: Jacksonville, FL

Start Loop Activity Stage - want to source a parmfile.txt

Post by lpadrta »

I'm working on a JobSequencer that calls a server job inside a loop. It's possible to use the Start_Loop_Activity stage to pass delimited parameter values to a server job inside a loop, one for each trip through the loop. But I want to get the parameters from a text file.

I've tried to do this in the GUI designer, but I can't seem to figure out how to do it. I've tried giving the path and file to the Start_Loop_Activity stage, along with a carriage return/newline delimiter, but I haven't been able to make it work. So I'll probably just code this.

Has anybody come across a way to get the Start_Loop_Activity stage to source a set of parameters directly from a text file?

For example, here's what I would put in a text file:
Row1 - Parameter1_value, Parameter2_value
Row2 - Parameter1_value, Parameter2_value
Row3 - Parameter1_value, Parameter2_value

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

Post by ray.wurlod »

Assuming that there aren't too many lines in the file, you could read the entire file into an array, or a delimited string, using a Routine activity, then use something like a Field() function to extract the appropriate line number. Make use of the fact that DataStage BASIC translates line terminator characters into field marks (@FM).

Code: Select all

FUNCTION ReadFile(Pathname)
* Returns contents of file as @FM-delimited string
Ans = ""

* Decompose pathname into directory and entry name portions
Call !GET.PATHNAME(Pathname, Directory, EntryName, Status)

* Open directory as if it were a table
OpenPath Directory To Dir.fvar
Then

   * Read entire file as if it were a record in a table
   Read Ans From Dir.fvar, EntryName
   Else
      Ans = ""  ; * file does not exist
   End

   Close Dir.fvar  ; * file no longer needed - free file handle

End  ; * end of OpenPath statement

RETURN(Ans)
Line number N from this file is obtained with the expression

Code: Select all

Field(RoutineActivity.$ReturnValue, @FM, N, 1)
Note that this technique does not work in versions earlier than 7.5, in which expressions become available in derivations.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
lpadrta
Premium Member
Premium Member
Posts: 38
Joined: Thu Nov 07, 2002 7:39 am
Location: Jacksonville, FL

Post by lpadrta »

Thanks for the help, Ray! Seems there is always a way to do what you want in DataStage, or even more than one way.

I'll give it a try tomorrow after I've had a little beauty sleep.

Lynda
Post Reply