Announcement:
wanna exchange links? contact me at sapchatroom@gmail.com.
Posted by
Admin at
Question from Pheonix on Apr 9 at 11:51 PM Hi, I am trying to use scripting to send out email notification if the jobs are in Error, Killed and Canceled status. However, I am unable to get email notification when the job is canceled. It's work well for Error and Killed. Below is my script. Anyone can help on this? { //Standard jobs String strTrapJobDef = "System_SNMP_SendTrap"; String strMailJobDef = "System_Mail_Send"; String strImportCCMSJob = "SAP_ImportCcmsJobs"; String strImportVariant = "SAP_ImportVariants"; //Attached log in notification email String strJobFile = "joblog.log"; String strJobFile2 = "stdlog.log"; //Application folder // String strApplication = "AMD_Training_Demo"; String strApplication = "AMD_FICO_SAP"; //Status Check (E,A,K,U) processed only and do not create an email for Standard jobs and email type job. if((jcsPostRunningContext.getNewStatus().equals(Jo bStatus.Error) || jcsPostRunningContext.getNewStatus().equals(JobSta tus.Canceled) || jcsPostRunningContext.getNewStatus().equals(JobSta tus.Killed) || jcsPostRunningContext.getNewStatus().equals(JobSta tus.Unknown) ) && ! "Mail".equals(jcsJob.getJobDefinition().g etJobDefinitionType().getName()) && ! strTrapJobDef.equals(jcsJob.getJobDefinition().get Name()) && ! strMailJobDef.equals(jcsJob.getJobDefinition().get Name()) && ! strImportCCMSJob.equals(jcsJob.getJobDefinition(). getName()) && ! strImportVariant.equals(jcsJob.getJobDefinition(). getName()) //&& "JobChain".equals(jcsJob.getJobDefinition ().getJobDefinitionType().getName()) && strApplication.equals(jcsJob.getJobDefinition().ge tParentApplication().getName())) { int intJobId = jcsJob.getJobId().intValue(); String strJobId = Integer.toString(intJobId); //build the system_mail_send job to submit JobDefinition jd = jcsSession.getJobDefinitionByName("System_Mai l_Send"); Job subjob = jd.prepare(); String strSubject = jcsJob.getJobDefinition().getName() + " (" + strJobId + ") ended with status " + jcsPostRunningContext.getNewStatus(); String strMessage = "Job Definition= " + jcsJob.getJobDefinition().getName() + "\nJob Id= " + strJobId + "\nStatus= " + jcsPostRunningContext.getNewStatus(); strMessage = strMessage.concat("\nDescription= " + jcsJob.getJobDefinition().getDescription()); subjob.getJobParameterByName("Subject"). setInValueString(strSubject); subjob.getJobParameterByName("Text").set InValueString(strMessage); //attach the log file if (jcsJob.getJobFileByName(strJobFile) != null) { subjob.getJobParameterByName("RelativeJob&quo t;).setInValueString(strJobId); subjob.getJobParameterByName("JobFile"). setInValueString(strJobFile); } else { subjob.getJobParameterByName("RelativeJob&quo t;).setInValueString(strJobId); subjob.getJobParameterByName("JobFile"). setInValueString(strJobFile2); } //Set a default user String strTo = " email@removed "; //build who to send it to by getting email address from application's documentation tab if (jcsJob.getJobDefinition().getParentApplication() != null) { Application appl = jcsJob.getJobDefinition().getParentApplication(); if (appl.getName() != null) { Object unknownObject = null; String strComment = appl.getComment(); if (strComment != unknownObject) // if there is comment exists { if (strComment.indexOf("@") > -1) // indexOf(String target) method searches left-to-right inside the given string for a "target" string. //The indexOf() method returns the index number where the target string is first found or -1 if the target is not found. { strTo = strComment; } } } } subjob.getJobParameterByName("To").setIn ValueString(strTo); } } | Reply to this email to post your response. __.____._ | _.____.__ |