Job Control Error

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
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Job Control Error

Post by sri75 »

HI,

I have routine to send an email when job gets aborted.
It is working fine so far.Now I wanted to reset the job after sending mail.I added few lines to that routine .I am getting following error

.AfterJob (DSAttachJob): Job control error (-12)
(DSOpenJob) Invalid job name '1'

I added
hJob = DSAttachJob(DSJ.ME, DSJ.ERRWARN)

hJob = DSPrepareJob(hJob)
these 2 lines to reset the job

this is the routine

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 


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

JobHandle = DSJ.ME 
JobName = DSGetJobInfo(JobHandle,DSJ.JOBNAME) 

call DSLogInfo("Job Name":JobName, "DSSendMail");  
J1stat = DSGetJobInfo(DSJ.ME,DSJ.JOBINTERIMSTATUS);


Jobstat = DSGetJobInfo(DSJ.ME,DSJ.JOBSTATUS);


StartTimestamp = DSGetJobInfo(JobHandle,DSJ.JOBSTARTTIMESTAMP);
EndTimestamp = DSGetJobInfo(JobHandle,DSJ.JOBLASTTIMESTAMP);

SummaryArray = DSGetLogSummary (JobHandle, DSJ.LOGANY,StartTimestamp , EndTimestamp , 50)

hJob = DSAttachJob(DSJ.ME, DSJ.ERRWARN)


If  J1stat =2 or J1stat=3 Then

hJob = DSPrepareJob(hJob)

Line="Failed or completed with warnings" 
message=''
message=InputArg:"\nBody:"
message=message :JobName:J1stat:Line :"\n" :JobHandle :StartTimestamp : "\n" : SummaryArray

Reply = DSSendMail(message) 

End
Can you please help me in finding the problem

Thanks
Sri
Ronetlds
Participant
Posts: 28
Joined: Thu Mar 30, 2006 12:48 pm

Post by Ronetlds »

Did you try using JobHandle instead of DSJ.ME as jobname in the DSAttachJob function?
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

Read the help file about DSAttachJob - you should be using the jobname, not DSJ.ME or JobHandle. One thing the help file says is
A job cannot attach to itself.

which is what I believe you are currently doing.

John
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

After obtaining the job name check that that value is not DSJE.BADHANDLE (which means that the attach failed).
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 »

No, I think John has it right - don't attach to yourself. However, you have a bigger problem. After Job is really after the job, it hasn't actually finished yet, which means you can't "reset" it because it is still running.

This needs to happen outside the job in your job control, and I personally never 'auto reset' immediately after a job aborts, you lose information that way. I check and reset a job before it is run as part of the start-up processing.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sri75
Premium Member
Premium Member
Posts: 132
Joined: Thu Sep 09, 2004 12:42 pm

Post by sri75 »

Hello to All,


Thanks for your suggestions and help.

I tried to use JobName and also JobHandle, simply job hangs

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

Post by chulett »

Because, as previously noted, you cannot attach to 'yourself'.
-craig

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