JCL JOB CONTROL LANGUAGE (JCL) Job Control Language is a means of communication between a program that can be written in COBOL or Assembler or PL/1 & MVS operating system. Why JCL? Job Control language is a flexible, powerful and unique language that runs in an IBM Mainframe environment. In addition to above charateristics, it appears to be quite incomprehensive and not user- friendly. Unlike programs written in programming languages like C, C++, PASCAL, FORTRAN, and COBOL etc. compiled under PC, MS-DOS or UNIX operating systems for the programs written in such languages to run on IBM-mainframe environment you have to submit the job to mainframe operating environment through JOB CONTROL LANGUAGE (JCL). JCL was created at a time when "user friendly" environments were not an issue, instead power and flexibility were. Job is a collection of statements that specify the resources required to run the job by the operating system. A mainframe is one of the greatest creation of mankind. It is something like, if you are working with the mainframe that actually means that you are the person working with the REAL computer with your colleagues. JCL is not a procedure Oriented Language like COBOL, PASCAL, C.. ect. JCL is not a Object Oriented Language like C++ or small talk. It has a uniquely identifying characters of its own, it is a job control language. JCL will identify to the operating system the resources that your program expects to use. It is the interface between the Application program and the MVS operating system that your program will run in. Without JCL your programs will not run in the IBM-Mainframes. INTRODUCTION TO JCL WHAT IS JCL? STRUCTURE OF JCL Using JCL you can tell the system what program(s) you want to run; what datasets these program(s) will be using; what should be done with those datasets once the program(s) end(s). JCL statements are used to input this information to the system. JCL is used to describe these Jobs. 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
JCL
JOB CONTROL LANGUAGE (JCL)
Job Control Language is a means of communication between a program that can bewritten in COBOL or Assembler or PL/1 & MVS operating system.
Why JCL?Job Control language is a flexible, powerful and unique language that runs in an IBM Mainframe environment. In addition to above charateristics, it appears to be quite incomprehensive and not user-friendly. Unlike programs written in programming languages like C, C++, PASCAL, FORTRAN, and COBOL etc. compiled under PC, MS-DOS or UNIX operating systems for the programs written in such languages to run on IBM-mainframe environment you have to submit the job to mainframe operating environment through JOB CONTROL LANGUAGE (JCL).
JCL was created at a time when "user friendly" environments were not an issue, instead power and flexibility were. Job is a collection of statements that specify the resources required to run the job by the operating system. A mainframe is one of the greatest creation of mankind. It is something like, if you are working with the mainframe that actually means that you are the person working with the REAL computer with your colleagues. JCL is not a procedure Oriented Language like COBOL, PASCAL, C.. ect. JCL is not a Object Oriented Language like C++ or small talk. It has a uniquely identifying characters of its own, it is a job control language. JCL will identify to the operating system the resources that your program expects to use. It is the interface between the Application program and the MVS operating system that your program will run in. Without JCL your programs will not run in the IBM-Mainframes.
INTRODUCTION TO JCL
WHAT IS JCL?
STRUCTURE OF JCL
Using JCL you can tell the system
what program(s) you want to run;
what datasets these program(s) will be using;
what should be done with those datasets once the program(s) end(s).
JCL statements are used to input this information to the system.
JCL is used to describe these Jobs.
A Job contains Steps.
Each Step signifies the execution of a Program.
Each Step has its own set of Data definitions.
1
JCL
All the Steps in a Job are executed sequentially i.e. one after the other.
A JCL statement consists of one or more 80-byte records.
A Continued JCL statement can begin in column 4-16.
Each statement is divided into the five fields:
1. IDENTIFIER FIELD
Indicates a JCL statement:- // in columns 1 and 2 of all JCL statements except the delimiter.- /* or installation designated characters in columns 1 and 2 as a delimiter.- //*in columns 1,2, and 3 depicts a comment statement
2. NAME FIELD
Identifies a statement so that it can be referred to later:- Must begin in column 3.- 1-8 characters in length (alphanumeric or national(#,@,$))- First character must be alphabetic or national.- Must be followed by at least one blank.
3. OPERATION FIELD
Specifies the type of statement or command:
- Follows the NAME Field- Must be preceded and followed by at least one blank.- Consists of characters specified in syntax for statement.
4. PARAMETER FIELD
Contains parameters separated by commas:
- Follows the OPERATION field.- Must be preceded and followed be at least one blank- Consists of two types:- Positional- Keyword
5. COMMENT FILED:
Can contain any information:
- Follows the PARAMETER field- Must be preceded by at least one blank - Difficult to use. Comment statement is recommended.
2
JCL
THE JOB STATEMENT
1. Objectives2. Purpose of the JOB statement3. Syntax4. Parameters
ACCOUNTING INFORMATION AND PROGRAMMER NAME CLASS MSGCLASS NOTIFY MSGLEVEL REGION TIME RESTART
TYPRUN5. Examples6. SummaryOBJECTIVES OF JOB STATEMENTUnderstand what the JOB statement accomplishes
Learn the most important parameters for the JOB statement
3
JCL
Code the different JOB statements depending on the need of the Job
PURPOSE OF JOB STATEMENT
The JOB statement is needed for the following reasons To identify the Job and the person who submitted the Job. Specify which Class the Job is to belong to. Specify how the output should be handled. To make an entity or group accountable for the execution of the Job. The JOB statement should always be the first statement in a Job. You can code more than one Job in the same member
SYNTAX OF JOB STATEMENT
The JOB statement accepts both positional and keyword parameters.
Example:
//Jobname JOB Parameters,……,// Parameters,…..
You can give the same Jobname for more than one of your Job. Internally the Job gets assigned a unique Job identification number.
PARAMETERS OF JOB STATEMENTACCOUNTING INFORMATION AND PROGRAMMER NAME
A Job contains Steps.
Type : Positional parametersAccounting information and Programmer's name are both positional parameters. Accounting information appears first followed by Programmer name.
Accounting information : An installation dependent value rangingFrom 1 to 143 characters.
Absence of a value must be shown by a comma.
Mainly used for billing purposes.
Programmer name: A character string ranging from 1 to 20 characters.
Absence of a value must be shown by a comma.
Appears at the bottom of every page of printed output for the Job.
Examples:
4
JCL
//MYJOB JOB MTPLACC25,'Ryaz Ahmed',…….
//YOURJOB JOB ,'Probir Bairagi',….
//HISJOB JOB MTPLAC30,,……..
Each Step signifies the execution of a Program.
Each Step has its own set of Data definitions.
All the Steps in a Job are executed sequentially i.e. one after the other.
A JCL statement consists of one or more 80-byte records.
A Continued JCL statement can begin in column 4-16.
Each statement is divided into the five fields:
1. IDENTIFIER FIELD
Indicates a JCL statement:
- // in columns 1 and 2 of all JCL statements except the delimiter.- /* or installation designated characters in columns 1 and 2 as a delimiter.- //*in columns 1,2, and 3 depicts a comment statement
2. NAME FIELD
Identifies a statement so that it can be referred to later:
- Must begin in column 3.- 1-8 characters in length (alphanumeric or national(#,@,$))- First character must be alphabetic or national.- Must be followed by at least one blank.
3. OPERATION FIELD
Specifies the type of statement or command:
- Follows the NAME Field- Must be preceded and followed by at least one blank.- Consists of characters specified in syntax for statement.
4. PARAMETER FIELD
Contains parameters separated by commas:
- Follows the OPERATION field.- Must be preceded and followed be at least one blank- Consists of two types:
5
JCL
- Positional- Keyword
5. COMMENT FILED:
Can contain any information:
- Follows the PARAMETER field- Must be preceded by at least one blank - Difficult to use. Comment statement is recommended.
As we have seen in Unit 1, the Class of a Job determines the input priority (a basis for Initiator selection)
As most installations do not prefer the users specifying the dispatching priority for their Jobs, the Class parameter provides a less explicit way to specify the input priority. For example, the user might select a Class, which most Initiators can handle.
MSGCLASS
Type: Keyword parameter
Purpose: To specify how the Job's output is to be handled.
Using the MSGCLASS parameter, you can tell the system how to handle the output of your Job.
The valid values that you can specify for this parameter are dependent on your installation.
6
JCL
In one installation, MSGCLASS=Z may mean that the output has to be immediately routed to a printer. In another installation, it may mean that the output has to be held in the Output Queue for later retrieval.
NOTIFY
Type: Keyword parameter
Purpose: To specify which user is to be notified after the Job finishes execution.
Syntax:
NOTIFY=User-Id
(Any valid User ID defined to RACF)
Example:
NOTIFY=USERIDNOTIFY=MAIN006
Once the Job ends execution, in case someone has to be notified about the completion along with the maximum return-code (discussed later) of the Job or, the Abend Code, the NOTIFY parameter has to be used.
Once the Job finishes, if the user specified in NOTIFY has logged on, he will get the message once he presses ENTER or any other Attention Identifier Key. If he is not logged on, he will get the message(s) along with his logon prompts the next time he logs on.
Purpose: To specify how much output has to be generated for this Job by the system.
Syntax:
MSGLEVEL=(a,b)
a: Specifies how much of the Job has to be printed in the output (job log).Valid values are 0, 1 and 20 - Print only the Jobcard (JOB statement of the Job)1 - Print all JCL and JES statements including all statements in procedures, if any2 - Print only submitted JCL and JES statements. Statements in procedures are not printed.
b: Specifies which messages will be printed in the output (job log).Valid values are 0 and 10 - Print All the messages only if the Job abends(abnormal termination).1 - Print All the messages regardless of the outcome of the Jobhow the job terminates
7
JCL
Examples:
MSGLEVEL=(1,1)
MSGLEVEL=(,1)
MSGLEVEL=(2,)
REGION
Type: Keyword parameter
Purpose: To limit the maximum amount of memory that the Job can utilize.
Syntax:
REGION=nnnnnnnKor REGION=nnnnM
n: Numeric value
Valid ranges :
0 thru 2047000 in case of K0 thru 2047 in case of M
K: Kilobytes
M: Megabytes
Examples:
REGION=1024K
REGION=1M
REGION need not be explicitly coded unless specified in the documentation for certain utilities.
If REGION=0K or REGION=0M is coded, the system assumes a default region size.
TIME
Type: Keyword parameter
Purpose: To specify the maximum processor time that the Job can utilize.
8
JCL
TIME = (minutes, seconds)
ON JOB STATEMENTMAX CPU TIME FOR JOBON EXEC STATEMENTMAX CPU TIME FOR STEP
1. The TIME parameter can be used to specify the maximum length of CPU time that a job or job step is to use the processor.2. If coded on the JOB statement, this is the total time for all steps.3. If coded on an EXEC statement, it is the maximum time for this step.4. Any combination of minutes and seconds can be coded. However, there are three values for the parameter that have a special meaning:
TIME=NOLIMIT means the job or step is not to be timed. TIME=1440 is equivalent to coding TIME=NOLIMIT. Thus 1440 is the only
numerical value of TIME that is not to be interpreted literally.( This indicates that the job will not be timed.)
TIME=MAXIMUM means the job or step will be allowed to use to 357912 minutes. ( this is about 8.25 months of processor time)
If coded on the JOB statement and any step causes the total time to be exceeded, the job is abnormally terminated.
If not coded, the JES installation default is used.
EXAMPLE
The entire job will be limited to a maximum of 1 minute and 30 seconds. The first step will be limited to a maximum of 1 minute.
Note that the submitter is apparently asking that the last step not be timed.However, coding TIME=NOLIMIT on the last step will NOT accomplish this Objective. The TIME=(1,30) on the JOB statement will limit the maximum time for step 3 to 1 minute and 30 seconds. What will be the minimum time available to step 3?
How could the submitter modify the JOB statement time so that step 3 would not be timed?
RESTART
Type: Keyword parameter
Purpose: To begin the execution of the Job from a Step other than the first one.
9
JCL
Syntax:
RESTART=Stepname
Example:
RESTART=STEP2
If you want to skip one or more of the initial steps in the Job before starting execution, use the RESTART parameter.
For example, if you have run a Job with 2 steps, the first step runs and the second step abends. You make the changes in the second step to set right any error causing statement or parameter. Now, you will require running only the second step. Therefore, you change the Job statement and add the RESTART parameter to start execution from the second step onwards.
If the time consumed by a job (or step) exceeds the value specified for the TIME parameter for that job (or step), the job ABENDS.
TYPRUN
Type: Keyword parameter
Purpose: To control the type of execution for the Job.
Syntax:
TYPRUN=SCAN
TYPRUN=HOLD
TYPRUN=COPY
SCAN: Only check the Job for syntax errors. Do not execute the Job.
HOLD: Check the Job for syntax errors and hold it in the Input Queue.
COPY: Send the Job directly to the Output Queue.
With SCAN, the Job gets checked for syntax errors. The output, including error messages, if any, is directly sent to the Output Queue.
With HOLD, the Job is checked for syntax errors. If no errors are present then, the Job is held in the Input Queue from where the operator will have to release it for execution.
With COPY, no syntax checking or execution takes place. The source content of the Job immediately gets directed to the Output Queue.
EXAMPLES OF JOB STATEMENTFollowing are a few sample JOB statements
It is a good practice to code individual parameters on separate lines as, if one of the parameters needs to be cancelled, all you need to do is comment out the line containing the parameter.SUMMARY OF JOB STATEMENTKnowledge supposedly gained after this unit
A thorough understanding of the purpose of the JOB statement
The most important parameters for the JOB statement Coding and identifying different types of JOB statements depending on the
requirements of the Job
THE EXEC STATEMENTTable of contents
Purpose of the EXEC statement
Syntax
Parameters
PGM PROC REGION TIME PARM
Examples
PURPOSE OF EXEC STATEMENTThe EXEC statement is needed for the following reasons
- To specify what programs need to be run.
- To specify which procedures (covered in later units) need to be run
- To specify the system requirements for each step if not coded in the JOB statement.
11
JCL
There can be a maximum of 255 steps in a Job. In other words, one Job can execute a maximum of 255 programs.
SYNTAX OF EXEC STATEMENTThe EXEC statement accepts one positional keyword parameter and other keyword parameters.
Example:
//Stepname EXEC PGM=Program-name
or
//Stepname EXEC PROC=Procedure-name
or
//Stepname EXEC Procedure-name
PARAMETERS OF EXEC STATEMENT
PGM
Type: Positional keyword parameter
Purpose: To name the module to be executed in the step
Syntax:
PGM=Program-name
Example:
PGM=MYPROG
PROC
Type: Positional keyword parameter
Purpose: To name the Procedure to be executed in the step.
Syntax:
PROC=Procedure-name
Example:
PROC=MYPROC
REGION
12
JCL
Type: Keyword parameter
Purpose: To specify the maximum memory that the step can utilize.
Syntax:
REGION=nnnnnnnKor REGION=nnnnM
Examples:
REGION=1024K
REGION=1M
TIME
Type: Keyword parameter
Purpose: To specify the maximum processor time that the step can utilize.
Syntax:
TIME=(mm,ss)
m: minutess: seconds
TIME=MAXIMUM
TIME=NOLIMIT
TIME=1440
PARM
Type: Keyword parameter
Purpose: To pass data to the load-module being executed in the step.
Syntax:
PARM=value
Example:
PARM='ABCDEFGH'
13
JCL
EXAMPLES OF EXEC STATEMENT
Following are a few sample EXEC statements
//STEP1 EXEC PGM=MYPROG,REGION=4M,// TIME=NOLIMIT
//STEP2 EXEC PROC=MYPROC
//STEP3 EXEC PGM=MYPROG,PARM='E001BROWN'
DD StatementPurpose of the DD statement SyntaxParameters
PURPOSE OF DD STATEMENT· The DD statement is required for the following reasons
- To define the datasets to be used by the step
- To create new datasets
- To manipulate existing datasets
- To specify all the dataset attributes while creating new datasets
- To provide instream data to programs
- To send information to the printer via the spool
SYNTAX OF DD STATEMENT
The DD statement accepts keyword parameters.
14
JCL
Example:
//DDname DD parameter,paramter,…
PARAMETERS OF DD STATEMENT
DSN
Type: Keyword parameter
Purpose: To specify the dataset name
Syntax:
DSN=dataset-name
Examples:
DSN=MAINUSR.COBOL.FILE
DSN=MAINUSR.DB2.FILES(DCLGEN)
DISP
Type: Keyword parameter that accepts positional parameters
Purpose:
Three-fold , to specify,
1) The status of the dataset at the beginning of the step.
2) Action to perform on the dataset if the step completes normally.
3) Action to perform on the dataset if the step abends.
Syntax:
Type: Keyword parameter that accepts positional parameters
15
JCL
Purpose: To specify the space requirements for new datasets
Syntax:
Unit: TRK - requests allocation in terms of tracks.
CYL - requests allocation in terms of cylinders.
Numeric value - requests allocation in terms of blocks with size specified by the numeric value.
Primary Quantity: Specifies the amount of initial allocation for the dataset in terms of the unit specified.
Secondary Quantity: Specifies the amount of additional allocation for the dataset in terms of the unit specified once the primary quantity is exhausted.
Directory Blocks: Specifies the Directory Blocks the dataset is to have. Any value greater than 0 creates a PDS. Coding 0 in this parameter or skipping it altogether creates a sequential dataset.
VOL
Type: Keyword parameter that accepts keyword and positional parameters
Purpose: To specify the Volume on which the dataset exists or needs to be created.
Syntax:
VOL=SER=volume-serial-number
UNIT
Type: Keyword parameter which accepts positional parameters.
Purpose: To specify what type of device the dataset resides on or should be created.
Syntax:
UNIT=Generic-unit-nameorUNIT=Unit-model-number
16
JCL
orUNIT=/Machine-address
Example:
UNIT=SYSDA
DCB
Type: Keyword parameter that accepts keyword parameters
Purpose: To tell the system about the characteristics of the dataset
Syntax:
DCB=(LRECL=nnnn,BLKSIZE=nnnn,RECFM=record-format)
LRECL - Specifies the maximum length of a record in the dataset. Values can range from 1 to 32760 bytes.
BLKSIZE - Specifies the maximum length of a block in the dataset. Values can range from 18 to 32760 bytes.
RECFM - Specifies the format of the records in the dataset i.e. fixed, variable, blocked, undefined etc.
Examples:
DCB=(LRECL=80,RECFM=FB,BLKSIZE=8000)
TEMPORARY DATASETS OF DD STATEMENT
OMIT DSN
//A DD UNIT=SYSDA, SPACE=(CYL,1)
DSN=&&WORK
//B DD DSN=&&WORK, UNIT=SYSDA, SPACE=(CYL,1)
DSN=&TEMP
//C DD DSN=&TEMP, UNIT=SYSDA, SPACE=(CYL,1)
1. A temporary data set is one that is created and deleted in the same job.2. There are three ways to request the creation of a temporary data set:
17
JCL
Omit the DSN. In this case the system will create temporary data set having a 44-character name. The system builds date, time, and other information into this name to ensure the name is unique.
Code a name beginning with && such as DSN=&&WORK. The system will create a temporary data set having a 44-character name. The system builds date, time, and other information into the name to ensure its uniqueness.
Code a name beginning with & such as DSN=&TEMP. The system will create a temporary data set with a 44-character name. The system creates a unique name containing date, time and other information. Names prefixed by && are preferable to those prefixed by &.
A temporary data set is created and deleted in the same job. It cannot be kept after the end of job.
To avoid ambiguity use the form, DSN=&&TEMP. To retain the dataset even after the current step ends, the temporary dataset
has to be passed to the next step by coding PASS in the second sub-option of the DISP parameter. If you have a Job of 3 step and you want to pass a temporary dataset from the 1st step to the 3rd step then, - Pass it from the 1st step to the 2nd- Pass it from the 2nd step to the 3rd.
REFER BACKS OF DD STATEMENTDSN = *.ddname *.stepname.ddnameSyntax:
You can use referbacks if you don't want to explicitly code the value for
parameters. Rather, you can obtain values from the same parameters in other steps.
The presence of the '*' above indicates that a backward reference is being used Many parameters in JCL statements can use a backward reference to fill in information. A backward reference (or referback) is a reference to an earlier statement in the job or in a cataloged or instream procedure called by a job step.
SPECIAL DD NAMES OF DD STATEMENTSTEPLIB Default search PDS for the load-module being run in the step
JOBLIB Default search PDS for the load-modules in the entire Job
SYSPRINT Default output dataset for printable outputs
SYSOUT Default output dataset for system messages
SYSIN Default instream input dataset for most programs
DATASET CONCATENATION OF DD STATEMENT
18
JCL
Concatenation is the method of combining 2 or more datasets and making them behave as a single file from the point of view of the program.
In case of input datasets records will be read in from files in the same order as specified in the concatenation i.e. start reading from the first file, once there are no more records in the first file, continue with the second file and so on until the last file is read. Only then will the system encounter the end-of-file condition.
In case of output datasets, writing will start from the first dataset. Once all the space in the first dataset is exhausted, the next dataset in the concatenation order will be written to and, so on.
PROCEDURES
What is a Procedure?
Instream and Cataloged Procedures
The PROC and PEND statements
The JCLLIB statement
Symbolic parameters
WHAT IS A PROCEDURE? For jobs that you run frequently or jobs that use the same JCL, pre-code job
control statements into procedures. Procedures consist of one or more complete steps. Every procedure must be given a name. Procedures are invoked via the E XEC statement. Three benefits of using procedures:
Saves time by reducing the time required to code JCL.Saves library storage by eliminating duplicate JCL.Reduces JCL errors by providing access to debugged JCL.
Example:
//STEP EXEC PROC=procedure nameor// STEP EXEC procedure name
19
JCL
INSTREAM PROCEDURE When you place a procedure in the job input stream, it is called an instream
procedure
1. Primarily used to test procedures.2. Reside in the job input stream and can be called only from that job stream.
Instream Procedures are those which are coded in the same member which contains the Job that uses them.
Instream Procedures can only be used by the Jobs that contain them.
CATALOGED PROCEDURES
A procedure cataloged in a library is called a CATALOGED PROCEDURE.
Can be called when needed Resides in a procedure library.
Cataloged Procedures are those which are contained in separate members and, are used by Jobs coded in different members.
Cataloged Procedures can be used by any Job coded in any member.
Procedures cannot contain JOB statements DD * statements DD DATA statements Delimiter statements('/*' followed by 78 blanks) Null statements('//' followed by 78 blanks) Non JCL statement(for example, JES or utility control statement)
CATALOGED PROCEDURES
THE JCLLIB STATEMENT
Using the JCLLIB statement you can specify the names of the PDSs that contain your Procedures which the Job will be using.
Even though JOBLIB and STEPLIB are DD names and JCLLIB is a statement, they have similar purposes.
JCLLIB is to Procedures what JOBLIB and STEPLIB are to Programs
THE SYMBOLIC PARAMETERS
20
JCL
Symbolic parameters are variables to hold values that can be changed when the Procedure is called
In the above example, A and B are the symbolic parameters. Instead of hardcoding the values for the VOL and UNIT parameters, they have been assigned the values contained in the symbolic parameters (Parameter=&Symbolic-parameter-name)
Symbolic parameter names can be a maximum of 8 characters long.
Utility Control Statement Syntax The IEBGENER Copy (card-disk) Utility. The IEBGENER Copy/Print Utility. The IEBGENER Utility The IEBPTPCH Utility The IEHLIST Utility The IEBCOPY Utility The IEHPROGM Utility The IEBUPDATE Utility The SORT Utility The MERGE Utility
OS/390 UTILITIES
Utilities are IBM-supplied programs that are intended to perform certain routine and frequently occurring tasks in the OS/390 environment.
Utilities can be used in DASD, tape, print and punch operations.
Utilities are also used to allocate,update,delete,catalog and catalog data sets, and also to list the contents of VTOC.
21
JCL
UTILITY CONTROL STATEMENT SYNTAX
The general format of a Utility Control Statement is :
[
Utilities during execution open and read the dataset described in the DD statement SYSIN.
The format in which SYSIN DD statement will appear is:
//SYSIN DD *
----control statements-----
/*
//SYSIN DD DSN=MAINTEC.CTLLIB(MEM),DISP=SHR
Utility control statements must be coded in columns 1 thru 71.
THE IEBGENER COPY (CARD-DISK ) UTILITY IEBGENER is a dataset utility used to create,copy,or print sequential data sets.
The above example allocates a dataset named ABC.SEQ,and then copies instream data to the dataset.
The EXEC statement specifies the program to be executed.The SYSPRINT DD statement defines the message dataset.The SYSUT1 DD statement defines the input dataset.The SYSUT2 DD statement defines the output dataset.The SYSIN DD statement defines the control dataset.This is where IEBGENER looks for utility control statements.