Job Status in Server transformer

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
DSMaestro
Participant
Posts: 14
Joined: Thu Oct 15, 2009 6:47 am

Job Status in Server transformer

Post by DSMaestro »

I was using the following code in the column derrivation of my server transformer to get the job status,

DSGetJobInfo(JobName, DSJobStatus)

but it was not reuturing any value.

Please help me in achieving it.

I've list of jobs avaialable in the project in a spreasheet as like below,

Job1
Job2
Job3
Job4

I was asked to get the output as like below,

Output:

Job1 Finished
Job2 Finished with warnings
Job3 Aborted
Job4 Not compiled
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Recheck the syntax. It requires a job handle, not a name, so you'll need to put it in a routine and add a call to DSAttachJob(), then call it with the appropriate InfoType:

Code: Select all

jHandle = DSAttachJob(JobName)
jStatus = DSGetJobInfo(jHandle, DSJ.JOBSTATUS
ErrCode = DSDetachJob(jHandle)
Begin Case
  Case jStatus = 1
     Ans = JobName : " Finished"
  Case jStatus = 2
     Ans = JobNAme : " Finished with warnings"
  Case jStatus = 3
     Ans = JobName : " Aborted"
End Case
I've left out any error handling and all possible case values but it's plenty to get you going.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You cannot check the job status of the current job because it should always be running.
Mamu Kim
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right... you can check but it will always show 'Running'. Bigger problem there is trying to issue an attach to yourself, that will hang - so make sure your list of job names does not include the checking job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You seem to have two threads operating for this question!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes, with some confused cross-talk but maybe that was just me. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSMaestro
Participant
Posts: 14
Joined: Thu Oct 15, 2009 6:47 am

Post by DSMaestro »

Hi,

I cereated the below routine with the name 'GetJobStatus'
$include DSINCLUDE JOBCONTROL.H
JobName=Arg1
JobHandle = DSAttachJob (JobName, DSJ.ERRFATAL)
controllerList=DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)
ErrCode=DSDetachJob(JobHandle);
Begin Case
Case controllerList = 1
Ans = "Finished"
Case controllerList = 2
Ans = "Finished with warnings"
Case controllerList = 3
Ans = "Aborted"
End Case
Called in my job through tranformer as follows
GetJobStatus(JobName)


I also placed a constraint in the transfomer to omit the job name that was calling the above routine...


It is generating the expected results.

Thanks...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What happens when the status is not a 1,2 or 3? The job name is invalid? Etc, etc. Need some error handling in there!
-craig

"You can never have too many knives" -- Logan Nine Fingers
poornima.chandramouli
Participant
Posts: 42
Joined: Wed Dec 26, 2007 1:58 am
Location: India

Post by poornima.chandramouli »

DSMaestro wrote:Hi,

I cereated the below routine with the name 'GetJobStatus'
$include DSINCLUDE JOBCONTROL.H
JobName=Arg1
JobHandle = DSAttachJob (JobName, DSJ.ERRFATAL)
controllerList=DSGetJobInfo(JobHandle,DSJ.JOBSTATUS)
ErrCode=DSDetachJob(JobHandle);
Begin Case
Case controllerList = 1
Ans = "Finished"
Case controllerList = 2
Ans = "Finished with warnings"
Case controllerList = 3
Ans = "Aborted"
End Case
Called in my job through tranformer as follows
GetJobStatus(JobName)


I also placed a constraint in the transfomer to omit the job name that was calling the above routine...


It is generating the expected results.

Thanks...
What is the staus code for the jobs having status Not Compiled, Reset, Running & your code doesn't include that?
Regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Look for a file called dsapi.h in (from what I recall) your DSEngine/include folder, it will list all exit / status codes for a job, amongst other things.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Best practice is to include a call to DSDetachJob() once you've finished with the job.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's in there. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply