z/OS Introduction and Workshop Job Control Language (JCL)

z/OS Introduction and Workshop
Job Control Language (JCL)
© 2012 IBM Corporation
© 2009 IBM Corporation
Unit Objectives
After completing this unit, you should be able to:
•Understand purpose of JCL
•Understand JCL JOB, EXEC, and DD statements
•Understand relationship of program file name to JCL DDNAME
•Locate JCL professional manuals, documentation, and online help
2
© 2012 IBM Corporation
JCL, Job Control Language
Computer code that tells the operating system what to do.
Job Control are the best words describing JCL.
The word "Language" in JCL could easily be replaced by
"Syntax" or "Commands" or "Statements".
JCL tells the computer what program to execute.
JCL provides a mechanism for the program to read input and
write output to requested physical resources.
3
© 2012 IBM Corporation
Job Control Language
JCL
1
2
JES
spool
6
JES
z/OS
3
4
5
Printer
4
7
1)
2)
3)
4)
5)
6)
7)
Program
Data
JCL submit
JCL requests program
Program loaded
JCL allocates resources needed by program
Resources provided to program
Program writes output to JES Spool
Output to printer as requested
© 2012 IBM Corporation
View JCL job
output written to
• JES spool
1
JES
spool
2
z/OS
JES
TSO
SDSF
1) TSO logon using SDSF panels to view JES spool output
2) JES spool output displayed on screen
5
© 2012 IBM Corporation
View JCL job
output written to:
• MVS Data Sets
• Unix files
2
1
z/OS
JES
TSO
ISPF
Data Sets
Unix files
1) TSO logon using ISPF panels to view program output on disk
2) Data displayed on screen
6
© 2012 IBM Corporation
JCL (Job Control Language)
z/OS written application programs include internal file names
which are opened for reading and writing during execution.
The program hard coded file names are only names that are not
associated with any physical resources.
JCL associates the program file name with physical resources
such has disk data set names or unix file names.
JCL is used to process programs in the background (aka 'batch')
and to process programs in the foreground (aka 'started task').
JCL submit will result in batch processing of one or more programs.
JCL start will result in foreground processing of processing program.
7
© 2012 IBM Corporation
JCL syntax fundamentals and execution
Job Control Language (JCL) instructs z/OS as a result of "submit” or "start “ command.
JCL is easily identified by // in column 1 and 2.
JCL is uppercase unless text is enclosed in quote marks such as unix file names.
Every batch JCL job must contain:
JOB statement
EXEC statement
JOB statement marks the beginning of a batch job and assigns a name to the job.
JCL started tasks do not require a JOB statement
EXEC (execute) statement marks the beginning of a job step, assigns a name to the
step, and identifies the program or procedure to be executed in the step.
Every batch job and started task has at least one EXEC statement.
8
© 2012 IBM Corporation
JCL – Job Control Language
 Job Control Language (JCL) is a sequential collection of 80 character
records beginning with // which the operating system reads and
interprets
 JCL is used to
• Assign name and authority level
• Assign resources (programs, data, etc.) and services needed
from the operating system to process a task
 JCL can be viewed as a list of statements to be ‘submitted’ for
background (batch) processing or ‘started’ for foreground (started task
) processing
9
© 2012 IBM Corporation
Minimum JCL batch JOB example:
//MYJOB JOB
//
EXEC
PGM=IEFBR14
JCL batch job example with stepname of STEP1:
//MYJOB JOB
//STEP1 EXEC
PGM=IEFBR14
JCL batch job example with multiple steps:
//MYJOB
//STEP1
//STEP2
//STEP3
10
JOB
EXEC
EXEC
EXEC
PGM=IEFBR14
PGM=IEFBR14
PGM=IEFBR14
© 2012 IBM Corporation
Job Control Language
//MYJOB JOB 1
//
EXEC PGM=IEBR14
1
2
JES
spool
4
JES Reader
z/OS
1)
2)
3)
4)
11
3
IEFBR14
JCL submit
JCL requests program
Program loaded
Output written to JES spool
© 2012 IBM Corporation
JCL DD statements
In addition to the JOB and EXEC statements, jobs may contain one or more DD
(Data Definition) statements used to identify and characterize the program input
and output.
Example:
//MYJOB
//STEP
//SORTIN
//SORTOUT
//SYSIN
//SYSOUT
JOB
EXEC PGM=SORT
DD parameters
DD parameters
DD parameters
DD parameters
JCL keyword DD is preceded by a 'DD name'.
The above JCL example has 4 'DD names',
SORTIN
SORTOUT
SYSIN
SYSOUT
12
© 2012 IBM Corporation
JCL DD statements
program input
program output
//MYJOB
//STEP
//SORTIN
//SORTOUT
//SYSOUT
JOB
EXEC PGM=SORT
DD parameters
DD parameters
DD SYSOUT=*
1
2
JES
spool
6
JES Reader
z/OS
1)
2)
3)
4)
5)
6)
13
3
4
5
Program
Data
JCL submit
JCL requests program
Program loaded
JCL //SORTIN DD
JCL //SORTOUT DD
JCL //SYSOUT DD SYSOUT=*
© 2012 IBM Corporation
Symbolic references to files
z/OS normally uses symbolic references to files (data sets) rather than
actual file names.
The use of symbolic references provides a naming redirection between a
data set-related name used in a program and the actual data set used
during execution of that program.
14
© 2012 IBM Corporation
JCL Referenced DDNAME
PAYROLL (program)
OPEN FILE=XYZ
READ FILE=XYZ
…..
CLOSE FILE=XYZ
JCL
//STEP1 EXEC PGM=PAYROLL
//XYZ
DD DSN=DIV1.PAYROLL
DATA SET
DIV1.PAYROLL
JCL is used to connect program file name to a z/OS physical resource such
as a data set name, unix file name, JES spool, printer, network device, etc.
//STEP1 EXEC
//XYZ
DD
PGM=PAYROLL results in open file=xyz
DSN=DIV1.PAYROLL is xyz content read by the program
DD is abbreviation for Data Definition
XYZ in this example is a program file name
XYZ in this example is also known as the JCL DDNAME
15
© 2012 IBM Corporation
JCL Referenced DDNAME
PAYROLL (program)
OPEN FILE=XYZ
READ FILE=XYZ
…..
CLOSE FILE=XYZ
JCL
DATA SET
//STEP1 EXEC PGM=PAYROLL
//XYZ
DD DSN=CORP.PAYROLL
CORP.PAYROLL
JCL enables ability for same program to read a different z/OS physical resource
without changing the program source code
16
© 2012 IBM Corporation
JCL DD statements
DD 'parameters' reference z/OS controlled resources such as
unix file name, data set name and data set status
Examples:
17
PATH=‘/unixpath/filename’
<<<< unix file name reference
DSN=DATA.SET.NAME
<<<< data set name reference
DISP=(start,end,abnormal_end)
<<<< disposition status of data set
© 2012 IBM Corporation
JCL DD DISP=values (resource disposition)
DISP=(
18
start
,end
[NEW]
[OLD]
[SHR]
[MOD]
[,
]
[,DELETE ]
[,KEEP
]
[,PASS
]
[,CATLG ]
[,UNCATLG]
[,
]
,abnormal_end
[,DELETE ]
[,KEEP
]
[,PASS
]
[,CATLG ]
[,UNCATLG]
)
OLD
SHR
NEW
MOD
resource exists and exclusive use is requested
resource exists and may be shared with other requestors
resource must be created, a new allocation
data set exists and records to be added at the end, or new data set
DELETE
KEEP
CATLG
UNCATLG
PASS
delete resource when program completes
keep resource when program completes
update catalog system to locate data set in the future
update catalog system remove location of resource
pass the resource to a subsequent JCL step
© 2012 IBM Corporation
JCL DD (Data Definition) statements
The program opens DD names as input, output, or both.
The program has an internal file name that will match the JCL DD name.
This association allows different data set names or unix file names
to be used by the same program without changing the internal
program file name.
When JCL batch job executes, the system writes output to the system controlled JES
output queue, data sets and/or unix files as directed by the JCL DD statements
19
© 2012 IBM Corporation
JCL - What is ‘batch’ processing?
Much of the work running on z/OS consists of programs called batch jobs.
Batch processing is used for programs that can be executed:
With minimal human interaction
At a scheduled time or on an as-needed basis.
After a batch job is submitted to the system for execution, there is normally no
further human interaction with the job until it is complete.
20
© 2012 IBM Corporation
JCL - What is ‘started task’ processing?
 A started task is typically a workload used for interactive processing
such as a transaction processing environment.
 The operating system consists of numerous started tasks.
 A started task will typically remain in the system until some action is
taken to stop the task.
21
© 2012 IBM Corporation
JCL - What is JES?
Job Entry Subsystem
 In the z/OS operating system, JES manages the input and output job
queues and data.
 JES handles the following aspects of JCL processing for z/OS:
 Reads JCL job into the operating system
 Interprets the JCL (variable substitution, etc.)
 Schedules job for processing
 Controls job output processing
22
© 2012 IBM Corporation
JCL, JES & Batch Processing
IT U S E R A C T IO N S
D e t e rm i n e
th e n e e d
and
c h a ra c t e ri s t i c s
o f th e J o b
C re a t e
th e J C L
S Y S T E M A C T IO N S
J E S i n t e rp re t s
JC L and
p a s s e s it to
z /O S in itia to r
S u b m it
th e J o b
z /O S
m anages
e a c h s te p
o f e x e c u tio n
S y s te m
M essages
U ser
v ie w s
and
i n t e rp re t s
o u tp u t
23
J E S p ri n t s
o u tp u t
J E S c o l le c ts
th e o u tp u t a n d
i n f o rm a t i o n
a b o u t th e J o b
© 2012 IBM Corporation
Fundamental JCL statements


24
The 3 basic JCL statements:
1) JOB statement
who wants to process work
2) EXEC statement
what program or procedure will be used
3) DD statement
what are the program inputs and outputs
Other useful JCL statements:
− PROC and PEND statement execute a JCL predefined procedure
−
INCLUDE statement
−
IF – THEN – ELSE – ENDIF provides JCL conditional processing
include predefined JCL statements
© 2012 IBM Corporation
JCL - Basic syntax
J C L m u s t b e u p p e rc a s e
F o r w a r d s la s h in c o lu m n 1 a n d 2
N a m e ( 1 - 8 c h a r a c t e r s ) f o llo w t h e s la s h e s
S p a c e s e p a ra to rs
/ /J O B N A M E J O B
/ /S T E P N A M E E X E C
/ /D D N A M E
DD
/ /* c o m m e n t - u p p e r o r lo w e r c a s e
/ * . .. . e n d o f d a t a
/ / . . .. e n d o f J C L
25
© 2012 IBM Corporation
JCL – example
//MYJOB
JOB 1
//MYSORT
EXEC PGM=SORT
//SORTIN
DD
DISP=SHR,DSN=ZIBM000.JCL(AREACODE)
//SORTOUT
DD
SYSOUT=*
//SYSOUT
DD
SYSOUT=*
//SYSIN
DD
*
SORT FIELDS=(1,3,CH,A)
/*
MYJOB is the jobname
MYSORT is the stepname
SORTIN is program input
SORTOUT is program output
SYSOUT is system output messages
SYSIN is control or data program input
26
© 2012 IBM Corporation
JCL - procedures (PROC to PEND)
//MYJOB
//MYPROC
//MYSORT
//SORTIN
//SORTOUT
//SYSOUT
//
PEND
27
JOB 1
PROC
EXEC PGM=SORT
DD
DISP=SHR,DSN=&SORTDSN
DD
SYSOUT=*
DD
SYSOUT=*
© 2012 IBM Corporation
JCL - procedures (continued)
//MYJOB JOB 1
//*------------------------------------------------------------------------------------------------*
//MYPROC
PROC
//MYSORT
EXEC
PGM=SORT
//SORTIN DD DISP=SHR,DSN=&SORTDSN
//SORTOUT DD SYSOUT=*
//SYSOUT
DD SYSOUT=*
//
PEND
//*------------------------------------------------------------------------------------------------*
//STEP1 EXEC
MYPROC,SORTDSN=ZIBM000.JCL(AREACODE)
//SYSIN
DD *
SORT FIELDS=(1,3,CH,A)
28
© 2012 IBM Corporation
JCL - procedures – PROC statement override
//MYJOB
JOB 1
//*------------------------------------------------------------------------------------------------------------*
//MYPROC
PROC
//MYSORT
EXEC PGM=SORT
//SORTIN
DD
DISP=SHR,DSN=&SORTDSN
//SORTOUT
DD
SYSOUT=*
//SYSOUT
DD
SYSOUT=*
//
PEND
//*--------------------------------------------------------------------------------------------------------------*
//STEP1
EXEC MYPROC,SORTDSN=IBMUSER.AREA.CODES
//MYSORT.SORTOUT DD DSN=IBMUSER.MYSORT.OUTPUT,DISP=(NEW,CATLG),
//
SPACE=(CYL,(1,1)),UNIT=SYSDA,VOL=SER=SHARED
//SYSIN
DD
*
SORT FIELDS=(1,3,CH,A)
29
© 2012 IBM Corporation
JCL - Specifying a data set disposition:
 DISP is an operand of the DD statement
 DISP indicates what to do with the data set (the disposition) at step
start, end, or abnormal end (if the job fails)
 DISP helps to prevent unwanted simultaneous access to data sets,
which is very important for general system operation.
30
© 2012 IBM Corporation
JCL - Using the DD statement DISP= operand
DISP=status
DISP=(status,normal_end)
DISP=(status,normal_end,abnormal_end)
where ‘status’ can be
– NEW
where ‘normal_end’ can be:
– OLD
 DELETE
– SHR
 KEEP
where ‘abnormal_end’ can be:
– MOD
 PASS
 DELETE
 CATLG
 KEEP
 UNCATLG
 CATLG
 UNCATLG
31
© 2012 IBM Corporation
JCL - Creating a new data set
 New data sets can be created through JCL by using the DISP=NEW parameter.
 For a DISP=NEW request, you need to supply more information, including:
 A data set name, DSN=
 The type of device for the data set, UNIT=3390 or UNIT=SYSDA or UNIT=SYSALLDA
 If a disk is used, the amount of space to be allocated for the primary extent must be
specified, SPACE=
 If it is a partitioned data set, the size of the directory must be specified within the
SPACE parameter
32
© 2012 IBM Corporation
JCL - Continuation and concatenation
 Needed to overcome the limitations of the 80-column punched cards used in earlier
systems.
33
•
Continuation allows a JCL statement to span multiple records.
•
Concatenation allows a single DDNAME to have multiple DD statements.
© 2012 IBM Corporation
JCL - Continuation and Concatenation
Continuation
//JOBCARD
JOB 1,
//
REGION=8M,
//
NOTIFY=IBMUSER
Concatenation
//DATAIN DD DISP=OLD,DSN=MY.INPUT1
34
//
DD DISP=OLD,DSN=MY.INPUT2
//
DD DISP=SHR,DSN=YOUR.DATA
© 2012 IBM Corporation
JCL - Utilities
 z/OS includes a number of programs useful in batch processing called utilities.
 Utilities provide many small, obvious, useful and often critical functions.
 Some examples of system utilities:
 IEBGENER Copies a sequential data set
 IEBCOPY
Copies a partitioned data set
 IDCAMSWorks with VSAM data sets
 IKJEFT01
Run any TSO workload in batch
 SORT
Data sequencing and formatting
35
© 2012 IBM Corporation
JCL and Utilities Documentation
 MVS JCL User’s Guide
 MVS JCL Reference
 DFSMSdfp Utilities
z/OS Concepts
Reusable JCL
Collection
36
© 2012 IBM Corporation
wikipedia.org
37
© 2012 IBM Corporation
Unit summary
Having completed this unit, you should be able to:
Understand purpose of JCL
Understand JCL JOB, EXEC, and DD statements
Understand relationship of program file name to JCL DDNAME
Locate JCL professional manuals, documentation, and online help
38
© 2012 IBM Corporation