cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the status of Redwood script

rubanprasanth_s
Participant
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

basv
Explorer
0 Kudos

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;
   }
}