Dynamic Job name as Email subject
Posted: Wed Oct 03, 2007 11:34 am
Hi,
I'm trying to create batch job which will go and check the status of jobs in particular categoty and email seperately or a common mail for all the jobs failed in category , The below code works and send seperate email if any job is aborted or finished with warnings
***************************************************
cmd="SELECT NAME FMT '60R' FROM DS_JOBS WHERE CATEGORY LIKE '%Chartfields\Fin_To_EPM\Server' ;"
Call DSExecute("UV",cmd,output,sysretcode)
Call DSLogInfo("Command Is: ":cmd,"Batch Job")
Call DSLogInfo("Output from the command: ":output,"Batch Job")
Final=""
n=DCount(output,@FM)
output=EReplace(output,Char(10),"")
For i=1 To n Step 1
A=Field(output,@FM,i)
JobName=Trim(A)
hJob1 = DSAttachJob(JobName, DSJ.ERRNONE)
Status = DSGetJobInfo( hJob1, DSJ.JOBSTATUS)
If
Status.RUNFAILED Or Status = DSJS.CRASHED OR Status = DSJS.RUNWARN
Then
Call DSExecute("UNIX",'/usr/bin/mailx -s hJob1 "a@yahoo.com"','0','0')
End
Next i
******************************************
Regards,
Munish
I'm trying to create batch job which will go and check the status of jobs in particular categoty and email seperately or a common mail for all the jobs failed in category , The below code works and send seperate email if any job is aborted or finished with warnings
***************************************************
cmd="SELECT NAME FMT '60R' FROM DS_JOBS WHERE CATEGORY LIKE '%Chartfields\Fin_To_EPM\Server' ;"
Call DSExecute("UV",cmd,output,sysretcode)
Call DSLogInfo("Command Is: ":cmd,"Batch Job")
Call DSLogInfo("Output from the command: ":output,"Batch Job")
Final=""
n=DCount(output,@FM)
output=EReplace(output,Char(10),"")
For i=1 To n Step 1
A=Field(output,@FM,i)
JobName=Trim(A)
hJob1 = DSAttachJob(JobName, DSJ.ERRNONE)
Status = DSGetJobInfo( hJob1, DSJ.JOBSTATUS)
If
Status.RUNFAILED Or Status = DSJS.CRASHED OR Status = DSJS.RUNWARN
Then
Call DSExecute("UNIX",'/usr/bin/mailx -s hJob1 "a@yahoo.com"','0','0')
End
Next i
******************************************
Regards,
Munish