Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stage Sequence Control

Status
Not open for further replies.

endyl13

Vendor
May 20, 2002
9
TH
Dear all,

How can I control the process of Stages that I have inside a job. Until now I only know that we can only control the process of jobs through Job Sequencer, or control the process of Output of Transform stage.

In my case, I have 4 stages in a job, Transform-1,Transform-2,Transform-3,Transform-4. I want to control the stages in the job to run in the correct order:
Transform-1 ==> Transform-2 ==> Transform-3 ==> Transform-4

If I can only do this through Job Sequencer, I need to create 4 jobs (with only 1 stage each) and a Job Sequencer, which is not efficient and easy to maintain for such a simple requirement.

Thank you...

Endy Lambey
 
Here's how:

First, create the function below (I call it "WaitForStage") as a before/after job routine:

*********************************************************
#include DSINCLUDE JOBCONTROL.H

StartTime = time()
Call DSLogInfo("Start waiting for ":InputArg, "WaitForStage")
StartSearch = DSGetNewestLogId(DSJ.ME, DSJ.LOGSTARTED)
BailOut = 0
StageList = UpCase(DSGetJobInfo(DSJ.ME, DSJ.STAGELIST))

InputArg = Trim(UpCase(InputArg))
NumStages = DCount(InputArg, ",")
StagesLeft = NumStages
Dimension Stage(NumStages)

for i = 1 to NumStages
Stage(i) = trim(field(InputArg, ",", i))

if index(StageList, Stage(i), 1) = 0 then
Call DSLogFatal("Invalid Stage Name: ":Stage(i), "WaitForStage")
ErrorCode = -1
Return

end

next

Loop While (1=1) Do
Sleep 3
EndSearch = DSGetNewestLogId(DSJ.ME, DSJ.LOGANY)
for i = EndSearch to StartSearch step -1
LogEntry = UpCase(DSGetLogEntry(DSJ.ME, i))
for j = 1 to NumStages
if (index(LogEntry, Stage(j), 1) > 0 and index(LogEntry, "ACTIVE STAGE FINISHING", 1) > 0) then
StagesLeft -= 1
Stage(j) = "a"

end

next

if StagesLeft = 0 then
BailOut = 1
exit

end

next
if BailOut = 1 then exit
StartSearch = EndSearch

Repeat

Call DSLogInfo("Finished waiting for ":InputArg, "WaitForStage")

Sleep 2

ErrorCode = 0 ;* set this to non-zero to stop the stage/job

*********************************************************

Then all you have to do is to select this function as the "before stage" function on a stage property page and specify the name of the stage it should wait for before it begins processing as the input argument.

Note: this one only works with transformer stages.

Good luck!
Deny
(by the way, I'm brazilian and looking for a job in the US as a Business Intelligence Technical Consultant)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top