JCL
基本概念
JCL编目过程
编目过程(Cataloged procedure)在系统管理和开发中有重要的作用。 在JCL的EXEC PROC语句中指定编目过程。 编目过程由Data Set的member确定;PROC和PEND是可选的,PROC语句不用来确定过程的名字。 编目过程可以放在系统过程库中(例如SYS1.PROCLIB),或者在调用过程的JCL中用JCLLIB或STEPLIB指定。 根据参考资料12,系统过程库在JES2 startup procedure的PROCxx DD语句中定义。 PROC和PEND在编目过程中不是必须的。使用PROC可以给过程提供默认的参数值。
JOBLIB, JCLLIB和STEPLIB
可以使用JOBLIB, JCLLIB, STEPLIB三者在JCL中指定程序库或过程库。
根据Reusable JCL collection中的JCL EXEC statements: How z/OS finds the program or procedure总结:
- EXEC PGM: JOBLIB,STEPLIB
- EXEC PROC:JCLLIB
JCL中
- 在JOB语句和第一个EXEC语句之间DD定义JOBLIB,则指定的库在整个JOB都使用
- 如果在一个作业步(EXEC)中定义STEPLIB,其定义的库只对该作业步有效。
- 如果在JCL中定义了JOBLIB或STEPLIB,系统首先搜索其定义的私有库,然后再搜索系统库。
Reusable JCL collection JCL EXEC statements: How z/OS finds the program or procedure To successfully run the program or procedure that you specify on a JCL EXEC statement, z/OS® has to search for and find that program or procedure. Using JOBLIB, STEPLIB, or JCLLIB statements can reduce search time. Where z/OS searches depends on what you specify in your JCL: • When you code the PGM parameter, z/OS looks for an application program, and will automatically search standard system program libraries, such as SYS1.LINKLIB, which contains IBM-supplied programs. If the program you want to run resides in a private program library, you must specify either a JOBLIB DD statement or a STEPLIB DD statement for z/OS to successfully locate the program. o When you use a JOBLIB DD statement, insert the JOBLIB DD statement in the job before the first EXEC statement in the job. When you submit the job, z/OS will search any private libraries specified on that JOBLIB DD statement before searching system libraries. z/OS repeats that search order for any programs called within the job. o When you use a STEPLIB DD statement, you may place it anywhere within a job step but it typically appears after the EXEC statement. When you submit the job, z/OS will search the private libraries specified on that STEPLIB DD statement, but only for the one step. • When you code the PROC parameter or you omit the PGM or PROC parameter, z/OS looks for a procedure and will automatically search standard system procedure libraries, such as SYS1.PROCLIB. If the procedure you want to run resides in a private library, you must specify the JCLLIB statement for z/OS to successfully locate the procedure. o If a job does not specify a procedure library, the system retrieves all cataloged procedures called by EXEC statements from the procedure libraries defined by the installation for the job's job class. To direct the system to search another procedure library, or to limit the procedure libraries it searches, code a JCLLIB statement that identifies one or more libraries. On a JCLLIB statement, you may list system libraries, installation-defined libraries, or private libraries. The system searches the libraries in the order in which they are specified on JCLLIB.
COND
EXEC语句的COND参数可以根据之前的作业步的返回值决定是否执行
语法:
COND=(CODE,OPERATOR,STEPNAME)
- CODE 可以为 [0-4095]
- Operator 可以为 GT, LT, GE, LE, EQ
- Stepname是可选的,如果省略则检查所有作业步的返回值
另外:
- COND=ONLY it allows step execution if any prior step is ABENDED
- COND=EVEN it allows step execution even if the prior step is ABENDED
例子:
如果4大于STEP1的返回值STEP2 将跳过//STEP2 EXEC PGM=PROG12,COND=(4,GT,STEP1)
MAximum 8 conditions can be coded in the COND parameter. In case of multiple conditions if ANY of the condition is found TRUE then the JOB stops proceeding further.
It bypasses the step if the condition is true.
From chapter 16.5 of the JCL Language Reference manual
The system performs the COND parameter tests against return codes from the current execution of the job. If a test specifies a previous step that was bypassed, the system evaluates the COND parameter as false.
IF语句
// IF (RC <= 4) THEN
//STEP2 EXEC ……..
// ENDIF
DD语句
DD语句参数 DISP=(Status,normal-disposition,abnormal-disposition)
Status: The status field tells the current status of a dataset i.e, whether dataset is exists or has to be created. Status values can be NEW,OLD,MOD,SHR
NEW: Status of the dataset is new and is not already exists. Going to create the new dataset
OLD: Dataset is already present.
MOD: Dataset may or may not exists. If not exists creates the new dataset. If exists then it's purpose is same as OLD.
SHR: Dataset can be used by multiple jobs at same time for read purpose
Normal-disposition: What to do with the dataset upon successful run of job
Normal-disposition values can be CATLG,DELETE,PASS,KEEP
CATLG: Save the dataset and creates the catalog entry.
DELETE: Delete the dataset
PASS: Pass the dataset to the next steps. After completion of job run delete the dataset
KEEP: Keep the dataset. But no information will be available in catlog table about the dataset.
Abnormal-disposition: What to do with the dataset upon unsuccessful run of job.
abnormal-disposition values can be CATLG,DELETE,KEEP