Description:
Depending on resource availability different jobs can be scheduled with CA ESP WA.
Solution:
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.
APPL APPL1 JCLLIB 'PROD.JCLLIB' CCCHK RC(1:4095) FAIL STOP OPTIONS RESTARTSTEP JOB JOB1 RUN NOW RESOURCE ADD(1,RESOURCE1) ABANDON SUBMISSION NOW PLUS 30 SECONDS RELEASE ADD(TASK1) ENDJOB JOB TASK1 TASK RUN NOW REXXON PROC 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)" End; End; REXXOFF ESP AJ TASK1 COMPLETE APPL(APPL1.%ESPAPGEN) RELEASE ADD(JOB2) ENDJOB JOB JOB2 RUN NOW ENDJOB
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.