JCL Session 9
LOAD
MODULE
is the executable machine language version of a source program.
In order to execute a load module, it must be stored in a PDS (library).
DCB of a load
module library is
RECFM=U,
LRECL=0 and BLKSIZE=6144
or greater.
Create a
new load module library using either
JCL or TSO/ISPF 3.2
The compile/link/go
procedure puts programs into a temporary PDS dataset and
then executes
the program via a referback in the GO step.
The GO step of
the compile, link and go procedure has an execute statement of
//GO EXEC PGM=*.LKED.SYSLMOD
which is a referback to a program
the library
created in the link edit step.
Make the current
COB2J procedure more readable using temporary datasets and
symbolic parameters.
To populate
the PDS with load modules:
- copy
a module from another load module PDS
- compile
and link a program
into the new PDS
(create
a PROC that does the Compile and Link
or use PROC member COB2CLJ of SYS1.PROCLIB
or use CL member from JPETLIC.CSC.CNTL)
MVS search SYS1.LINKLIB
as the default load library
when looking for programs.
To execute a
program saved in a library other than SYS1.LINKLIB, direct MVS to other
PDS load libraries by using STEPLIB DD
and/or JOBLIB
DD statement(s).
//STEPLIB
DD can be used after an EXEC statement
and will direct the system
to look in the
DSN= library only when executing that step.
i.e.
//stepname EXEC PGM=PARMCODE
//STEPLIB DD
DSN=CCPF##.CSC.LOAD,DISP=SHR
//JOBLIB
DD can be used after the JOB card and
will direct the system to look at the
specified DSN=
libraries in those steps which do not have a //STEPLIB DD statement.
i.e. //jobname
JOB (etc.)
//JOBLIB DD DSN=CCPF##.CSC.LOAD,DISP=SHR
//stepname EXEC PGM=PARMCODE
Load module libraries
may have to be reorganized because
each compile and linkedit of a program will cause replacement copies to
use a new data space.
PROGRAM STATUS
- a completion code number issued at a
program's termination.
As each program
returns control to the system, it gives the system its final program
status
as a coded number.
The final program
status number may be useful
-
for determining
whether to execute the subsequent programs,
-
MVS preserves the
program status number and makes it available
for job control.
IBM software using
the following convention regarding program execution:
COND CODE 0000 - program successful
COND CODE 0004 - warning messages
COND CODE 0008 - Serious flaws
COND CODE 0012 - Very serious flaws
COND CODE 0016 - Disaster
COBOL programmers control the final status of their programs by
moving a number to RETURN-CODE.
If RETURN-CODE is not used in the program, the
default number is zero.
i.e.
MOVE 16 TO RETURN-CODE
GOBACK.
COND CODE
- AN EXEC PARAMETER TO BYPASS STEP EXECUTION
Define conditions
which, when true, do not execute a
step.
Stated conversely,
if the condition is false, execute the
step.
When multiple
COND tests are listed, each acts as an
implicit
OR - any one test which is true will bypass
the step.
Why bypass a step? Why bypass any particular program?
FORMAT:
COND=((value,operator,stepname),(..,..,..))
value
- a number from 0 to 4095
operator
- GT - Greater than
LT - Less than
EQ - Equal to
NE - Not equal to
GE - Greater than or equal to
LE - Less than or equal to
stepname
- If present, the return code from a particular
step is used, otherwise the return codes from
all previous steps are used.
Which steps
are executed if the program at STEP010 returns a condition code of 3
and all other
steps, when executed, return a condition code of 0000?
//STEP010 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
SET LASTCC = 3
- - - - - -
//STEP020 EXEC PGM=IEFBR14,COND=(4,LT,STEP010)
//STEP030 EXEC PGM=IEFBR14,COND=(4,EQ,STEP010)
//STEP040 EXEC PGM=IEFBR14,COND=(4,GT,STEP010)
//STEP050 EXEC PGM=IEFBR14,COND=(4,NE,STEP010)
//STEP060 EXEC PGM=IEFBR14,
//
COND=((4,LE,STEP010),(2,GE,STEP010),(3,NE))
Special cases
COND=EVEN
Process this step even
if there is an abend
(Can still use
condition code test to bypass normal processing)
COND=((4,LT,STEP010),EVEN)
COND=ONLY
Process this step only
if there was an abend.
(Normal condition
code testing is turned off when there is an abend)
Example
// IF ( STEP010.RC =
0 ) THEN
//STEP020 EXEC PGM=IEFBR14
//STEP030 EXEC PGM=IDCAMS
// ELSE
//STEP040 EXEC PGM=IEBGENER
- - - -
//STEP050 EXEC PGM=SORT
- - - -
// ENDIF
-------------------------------------------------------------------------------------------------------------------------------
IF/ELSE CODING
RULES
IF has
to be idented at least one space from the slashes.
THEN word
is mandatory.
ENDIF
word is mandatory.
At least one
EXEC after an IF or ELSE.
Operators:
EQ =,
GT >,
LT <,
GE >=,
LE <=,
AND &,
OR | ,
NOT
NOT EQUAL,
NOT GREATER
>,
NOT LESS <,
ABEND,
RUN.
TRUE,
FALSE.
Compound AND
conditions can be tested.
i.e. // IF ( STEP010.RC >= 4
AND STEP020.RC = 0) THEN
PARM -
"PARAMETER" - a value which can be input to a program.
Up to 100 bytes
of information to a batch program through JCL PARM statement.
Why use PARM?
Code the PARM
statment directly when executing the program directly.
ie
//STEP020 EXEC PGM=PARMCODE,PARM='SALARIED'
To override a
PARM statement on PROCs, use the pattern PARM.procstepname
ie.
//STEP020
EXEC PROC=COB2J,PARM.GO='HOURLY'
IDENTIFICATION
DIVISION.
PROGRAM-ID.
PARMCODE.
ENVIRONMENT
DIVISION.
DATA
DIVISION.
WORKING-STORAGE
SECTION.
01
DISPLAY-NUMBER PIC ZZZ9.
LINKAGE
SECTION.
01
PARM-FIELDS.
05
PARM-CHAR-COUNT PIC S9(4) COMP.
05
PARM-INPUT PIC X(100).
PROCEDURE
DIVISION USING PARM-FIELDS.
MOVE
PARM-CHAR-COUNT TO DISPLAY-NUMBER
DISPLAY
'TOTAL CHARACTERS INPUT = ' DISPLAY-NUMBER
DISPLAY
'PARM FIELD PUT INTO PROGRAM IS = ' PARM-INPUT
MOVE
PARM-CHAR-COUNT TO RETURN-CODE
GOBACK.
IDENTIFICATION
DIVISION.
PROGRAM-ID.
PGMWPARM.
ENVIRONMENT
DIVISION.
INPUT-OUTPUT
SECTION.
FILE-CONTROL.
SELECT
GRADESI ASSIGN TO DATAIN.
SELECT
GRADESO ASSIGN TO DATAOUT.
-------
LINKAGE
SECTION.
01
PARMINFO.
05
PARM-LENGTH PIC S9(4) COMP.
05
PARM-DATA.
10
PARM-SCHOOL PIC X(3).
10
FILLER PIC X(97).
PROCEDURE
DIVISION USING PARMINFO.
------
DISPLAY
'LIST 'W-DISPLAY 'SCHOOLS'.
------
PRACTICAL JCL EXERCISE LOAD
LIBARIES, PARMS, & COND
(VALUE 30 POINTS)
Necessary preparation work that
should not be handed in.
A. Create a load library.
B. Copy PGMWPARM into your COBOL
library.
Change the program so that
it issues a return code of 0013
if no students attending the
school equal to the parm input.
The program should issue a return
code of 0000 if there are
students in the school equal
to the parm input.
C. Compile and link the altered
PGMWPARM program into your load libary.
D. Create and store, in your
proclib, a three step proc which will execute
1)
PGMWPARM in the first step, (use //STEPLIB DD reference)
(PGMWPARM should send all output to a temporary file).
The input is JPETLIC.CSC.CNTL(GRADES).
2) SORT
in the 2nd step, only if there is output from the first step,
(use
the COND= specification to test the result of PGMWPARM)
Sort by student name of the temporary file created by PGMWPARM.
3) IEBGENER
in the 3rd step to print the sorted temporary file
only if there is output from the first step and the sort step worked.
(Use the COND=
specification to test the result of PGMWPARM and SORT)
Work that should be handed in.
Exec your PROC twice
in one JOB
The first execution should
produce output because you feed
a parm that matches a school.
The second execution should not
produce output because
you feed a parm that does not
match a school. (this means
the sort and iebgener steps
should not execute).