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
Start Loop Activity Stage - want to source a parmfile.txt
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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).
Line number N from this file is obtained with the expression
Note that this technique does not work in versions earlier than 7.5, in which expressions become available in derivations.
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)
Code: Select all
Field(RoutineActivity.$ReturnValue, @FM, N, 1)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.