on 11-09-2017 5:14 AM
Hello SAP BPA Experts,
I am running a Redwood script ( Job Definition ) , which in turn calls multiple Job chains.
Redwoodscript needs to go to "ERROR" status when atleast one of the called job chain fails ( i.e. Redwoodscript needs to go to "COMPLETE" status when all the called job chain complete. )
By default, either the called job is success or failure the Status of redwood script is set as completed.
I could not able to find how to do this .So i request you to help me with this.
Thanks in Advance.
Regards,
Ruban.S
Hi Ruban,
Besides submitting the jobs from your script, you also have to do the error handling in your script.
Otherwise your script is finished after submitting your chains, and goes to completed regardless of the status of it's child jobs.
Add below code to you script after the part that submits your job chains:
jcsSession.waitForAllChildren(jcsJob); // Waits until all children of the current job are completed
jcsSession.refreshObjects(new SchedulerEntity [] {jcsJob}); // Refresh jcsJob with the latest information
// Loop over all child jobs, if any have a status other then 'Completed'
// set the main job to error.
for (final Iterator it = jcsJob.getChildJobs(); it.hasNext(); ) {
Job child = (Job) it.next();
if (!child.getStatus().equals(JobStatus.Completed)) {
jcsJobContext.setReturnCode(new Long(1)); //Set current job to Error
break;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.