Scheduling different jobs depending on resource availability with ESP Workload Automation.
search cancel

Scheduling different jobs depending on resource availability with ESP Workload Automation.

book

Article ID: 53091

calendar_today

Updated On:

Products

ESP Workload Automation

Issue/Introduction

How to build application to run multiple jobs depending on availability of resources in ESP

Resolution

When an application is generated that contains multiple jobs Example below using JOB1 and JOB2 with JOB1 requiring resource.

Example:
1. If the resources required by JOB1 are not available in a  period of 30 seconds, then JOB1 should not be submitted, and JOB2 should be submitted. 
2. If the resources are available in the specified time period then JOB1 should be submitted and JOB2 should not be submitted.

Scenario:
1. If JOB1 is not submitted in 30 seconds due to resource not available, then it is abandoned. The status is CSF would show EXEC ABANDONED.
    TASK1 uses JOBONCSF; an ESP built in function that can be used in REXX, to determine the status of JOB1. 

2. If the status is not EXEC ABANDONED then that means the job was submitted. Then APPLJOB (AJ) command is used to BYPASS JOB2 since it should not run. The task then completes itself and the application is completed.

3. If the status is EXEC ABANDONED then the task just completes itself and releases JOB2 which is then 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