You can not use this in a job design to achieve your aim. Nor can you use a DataStage macro (DSJobStatus) or DSGetJobInfo with DSJ.ME as the first argument, since these will always report the currently-executing job.
You need to create a routine (type is "transform function") which, given a name, returns that job's status. Since the current job is always "running" you can omit this from consideration.
Code: Select all
FUNCTION GetJobStatus(JobName)
$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
hJob = DSAttachJob((JobName), DSJ.ERRNONE)
JobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
If JobName Matches "'-'1N0N"
Then
* Unable to attach job
Ans = -1
End
Else
* Attached job, now ensure it's not this job
If JobName = DSGetJobInfo(DSJ.ME, DSJ.JOBNAME)
Then
Ans = 0
End
Else
* Otherwise get the job's status
Ans = DSGetJobInfo(hJob, DSJ.JOBSTATUS)
End
ErrCode = DSDetachJob(hJob) ; * this is a vital step!
End
RETURN(Ans)