Skip to Content

Setting the status of Redwood script

Nov 09, 2017 at 05:14 AM


avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member 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);
   if (!child.getStatus().equals(JobStatus.Completed)) {
      jcsJobContext.setReturnCode(new Long(1)); //Set current job to Error
10 |10000 characters needed characters left characters exceeded