Sequence_Activities


In this article i will explain how to use datastage looping acitvities in sequencer.
I have a requirement where i need to pass file id as parameter reading from a file.In Future file id’s will increase so that i don’t have to add job or change sequencer if I take advantage of datastage looping.
Contents in the File:
1|200
2|300
3|400
I need to read the above file and pass second field as parameter to the job.I have created one parallel job with pFileID as parameter.
Step:1 Count the number of lines in the file so that we can set the upper limit in the datastage start loop activity.
sample routine to count lines in a file:
Argument : FileName(Including path)
Deffun DSRMessage(A1, A2, A3) Calling “*DataStage*DSR_MESSAGE”
Equate RoutineName To “CountLines”
Command = “wc -l”:” “:FileName:”| awk ‘{print $1}’”
Call DSLogInfo(“Executing Command To Get the Record Count “,Command)
* call support routine that executes a Shell command.
Call DSExecute(“UNIX”, Command, Output, SystemReturnCode)
* Log any and all output as an Information type log message,
* unless system’s return code indicated that an error occurred,
* when we log a slightly different Warning type message.
vOutput=convert(char(254),”",Output)
If (SystemReturnCode = 0) And (Num(vOutput)=1) Then
Call DSLogInfo(“Command Executed Successfully “,Command)
Output=convert(char(254),”",Output)
Call DSLogInfo(“Here is the Record Count In “:FileName:” = “:Output,Output)
Ans = Output
*GoTo NormalExit
End Else
Call DSLogInfo(“Error when executing command “,Command)
Call DSLogFatal(Output, RoutineName)
Ans = 1
End
Now we use startLoop.$Counter variable to get the file id by using combination of grep and awk command.
for each iteration it will get file id.
Finally the seq job looks like below.
I hope every one likes this post.

3 comments:

pradyut said...

Hi all need some inputs
Suppose in a sequence I have 10jobs there are few jobs which will run on monday and few jobs will run on fridays and all the jobs will run on sundays. Please can you let me know how we can do that.

pradyut said...

Hi all need some inputs
Suppose in a sequence I have 10jobs there are few jobs which will run on monday and few jobs will run on fridays and all the jobs will run on sundays. Please can you let me know how we can do that.

pradyut said...

Hi all need some inputs
Suppose in a sequence I have 10jobs there are few jobs which will run on monday and few jobs will run on fridays and all the jobs will run on sundays. Please can you let me know how we can do that.