Batch Job - send email issue
Posted: Tue Oct 02, 2007 5:31 pm
Hi Gurus,
I've created a batch job which run all the jobs in parallel from a category.
I want to send an email if the job is finished with warnings with subject as job name or message as job name.
I'm able to send email for any jobs abort or finished with warnings but the subject is not dynamic i.e. Job Name , below is the code for same.
Thanks in advance for help
I even tried to create a normal batch job by adding all the jobs thru generated code and was able to send email individually but then jobs do not run in parallel I removed the dependency from dependency tab somehow they execute in sequence.
ProjName = DSGetProjectInfo (DSJ.PROJECTNAME)
TrimmedProjName = Field(Trim(ProjName), "_", 1, 2)
FolderName = 'chart'
cmd="SELECT NAME FMT '60R' FROM DS_JOBS WHERE CATEGORY LIKE '%abc\chart' ;"
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)
If IsNull(JobName)=1 OR Count(JobName,"...") > 0 OR Len(JobName) < 1 OR Count(JobName,"records listed.") OR Count(JobName,"\\\abc\chart")
Then
x=1
End Else
If Len(JobName) > 0 Then
* Setup JobName, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob(JobName, DSJ.ERRWARN)
ErrCode = DSRunJob( hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo( hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED OR Status = DSJS.RUNWARN
Then
Call DSExecute("UNIX",'/usr/bin/mailx -s JobName "a@yahoo.com"','0','0')
End
End
End
Next i
Call DSLogInfo("Batch Job Completed", "JobControl")
I've created a batch job which run all the jobs in parallel from a category.
I want to send an email if the job is finished with warnings with subject as job name or message as job name.
I'm able to send email for any jobs abort or finished with warnings but the subject is not dynamic i.e. Job Name , below is the code for same.
Thanks in advance for help
I even tried to create a normal batch job by adding all the jobs thru generated code and was able to send email individually but then jobs do not run in parallel I removed the dependency from dependency tab somehow they execute in sequence.
ProjName = DSGetProjectInfo (DSJ.PROJECTNAME)
TrimmedProjName = Field(Trim(ProjName), "_", 1, 2)
FolderName = 'chart'
cmd="SELECT NAME FMT '60R' FROM DS_JOBS WHERE CATEGORY LIKE '%abc\chart' ;"
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)
If IsNull(JobName)=1 OR Count(JobName,"...") > 0 OR Len(JobName) < 1 OR Count(JobName,"records listed.") OR Count(JobName,"\\\abc\chart")
Then
x=1
End Else
If Len(JobName) > 0 Then
* Setup JobName, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob(JobName, DSJ.ERRWARN)
ErrCode = DSRunJob( hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo( hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED OR Status = DSJS.RUNWARN
Then
Call DSExecute("UNIX",'/usr/bin/mailx -s JobName "a@yahoo.com"','0','0')
End
End
End
Next i
Call DSLogInfo("Batch Job Completed", "JobControl")