Dynamic Job name as Email subject

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
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

Dynamic Job name as Email subject

Post by shrey3a »

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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Isn't this the same issue as your other post? :?

Your other post at least showed you attempting to use the JobName, here you would send the job handle if it was working correctly. And it's not working because you buried the variable name in a string. You'd need to break the string around it and concatenate the variable in, fixing the quoting mess and your improper DSExecute syntax at the same time:

Code: Select all

Call DSExecute("UNIX","/usr/bin/mailx -s ":hJob1:" a@yahoo.com",Output,SystemReturnCode)
And then check SystemReturnCode for a non-zero return.
-craig

"You can never have too many knives" -- Logan Nine Fingers
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

Post by shrey3a »

Thanks great help its working now.

Thanks again!

[quote="chulett"]Isn't this the same issue as your [url=viewtopic.php?t=113507]other post?[/url] :?

Your other post at least showed you attempting to use the JobName, here you would send the [b]job handle[/b] if it was working correctly. And it's not working because you buried the variable name in a string. You'd need to break the string around it and concatenate the variable in, fixing the quoting mess and your improper DSExecute syntax at the same time:

[code]Call DSExecute("UNIX","/usr/bin/mailx -s ":hJob1:" a@yahoo.com",Output,SystemReturnCode)[/code]
And then check SystemReturnCode for a non-zero return.[/quote]
Post Reply