Depending on resource availability different jobs can be scheduled with CA ESP WA.
When an application is generated that contains multiple jobs, let's use JOB1 and JOB2. JOB1 requires certain resources. If the resources required by JOB1 are not available in a specified time period, say 30 seconds, then JOB1 should not be submitted and JOB2 should be submitted. If the resources are available in the specified time period then JOB1 should be submitted and JOB2 should not be submitted.
The following example shows how to code this.
CCCHK RC(1:4095) FAIL STOP
ABANDON SUBMISSION NOW PLUS 30 SECONDS
JOB TASK1 TASK
J = JobOnCSF('JOB1','X')
If J > 0 & XAPPL.J = 'APPL1' Then Do
If XSTATUS.J ?= 'EXEC ABANDONED' Then Do
"ESP AJ JOB2 BYPASS APPL(APPL1.%ESPAPGEN)"
ESP AJ TASK1 COMPLETE APPL(APPL1.%ESPAPGEN)
If JOB1 is not submitted in 30 seconds, which in this case would be because the resource is not available, then it is abandoned. The status is CSF would show EXEC ABANDONED.
The task TASK1 uses JOBONCSF; an ESP built in function that can be used in REXX, to determine the status of JOB1. If the status is not EXEC ABANDONED then that means the job was submitted. In this case the APPLJOB (AJ) command is used to BYPASS JOB2 since it should not run. The task then completes itself and the application is completed.
If the status is EXEC ABANDONED then the task just completes itself and releases JOB2 which is then submitted.