Skip to Content
avatar image
Former Member

Setting the status of Redwood script

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Nov 20, 2017 at 02:31 PM

    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;
       }
    }
    
    Add comment
    10|10000 characters needed characters exceeded