You are on page 1of 267

JCL

JOB Control Language


d

CHAPTERS
1) Introduction to JCL

2) Coding JCL
3) The JOB statement 4) The EXEC statement 5) The DD statement 6) More on DD statement 7) Utility programs 8) Procedures

9) Generation data groups

Chapter 1 Introduction to JCL

Typical Workloads to the Mainframe OS


What is a Workload?

Any work to be performed by the OS is called workload.

How is the work performed?


d The OS performs the work by executing the programs instructions.

Typical Workloads to the Mainframe OS

contd..

What are the typical workloads to the Mainframe OS?


Batch work
User
VTAM JES

Interactive work
User

OS
d
Printer Eg. Payroll report

BCP

OS
Storage device Eg. ATMs

Batch Work (also called Batch Processing)


Work performed without end user interaction.
Runs in the system background, freeing the user to do other work.

d
Normally scheduled to run when no interactive processing takes place. But when run concurrently with interactive tasks, batch work are typically given low priority by the OS.

BCP / JES / VTAM


Batch work
VTAM JES

BCP

Interactive users

BCP constitutes the core OS.

JES provides the interface between the BCP and the batch processes. d
VTAM provides the interface between the BCP and interactive users.

What is a JOB ?
The Batch process is called JOB. To render the Job to the OS we use Job Control Language (JCL).

JCL is the way to tell the OS:


which programs are to be executed which datasets are needed by the executing programs.

JCL also describes to the OS:


The Jobs name When the job is to be performed by the OS

The requestor of the job, among other things

The various JOBS


Job1
(Execution of your Application programs; say Cobol , PL/I programs)

Job2

JES BCP

(Execution of another users Application programs

Job3
(Execution of Subsystem programs to start TSO, CICS environments

The JCL Statements


A Job is coded using JCL.
JCL statements look like: //. //. //. JOB DD . . EXEC .

Through these statements you supply information and instructions to OS:

JOB - carries the Job name, the type of job //DSRC062 JOB CLASS= type of job
EXEC - carries the program name //STEP1 EXEC DD PGM=Load modules name DSN=Dataset name

DD - carries the datasets used by the program.


//DD1

10

The JCL Statements

contd

One JOB can execute more than one program.


//. //. //. //. JOB .

EXEC PGM=. DD EXEC PGM=.

//. d

DD

11

Looking back at the Jobs


Your Job:
//Job1 JOB . //. // // // EXEC Pgm=LM of Cobol program DD Exec Pgm=LM of PL/I program DD

Job2
(Execution of Application programs, by another user)

JES BCP

d Job3
(Execution of sub-system program to start TSO, CICS environments

12

A Jobs life cycle


The Job Enters the system The Job is placed in the Input Job queue The Job gets Executed by the OS The Job completes execution and moves to the Output queue, on to other devices.

J E S
d
Input queue

BCP
Execution

Output queue

JOB (JCL coded using TSO)

Redirect to other devices View / Purge Printer, Tapes, Disks

13

Jobs entering the system through TSO


The commonest way of Jobs entering JES is vide a Terminal software called TSO, Time sharing option

You code JCL with TSO and SUBMIT your JCL into the system for processing

You can view the output of your Job using TSO before redirecting the output to the desired destination Disk, Tape or Printer.

J E S
d
Input queue

BCP

Output queue

TSO //Job1 JOB .. //.. EXEC PGM=..

Redirect to other devices View / Purge Printer, Tapes, Disks

Submit

14

Jobs in the Input queue


After the Jobs are submitted:

JES gives each job a JOB ID which you can view and
Queues the jobs in the Input queue based on the jobs CLASS coded in the JCL.
Input queue Class E I Job ID Submit

J E S BCP
Output queue

TSO //Job1 JOB Class=I //.. EXEC PGM=..

View / Purge

Redirect to other devices Printer, Tapes, Disks

15

Jobs in the Input queue CLASS codes

contd..

Installations establish different Class codes based on the importance or type of job.

Class F for express jobs which use little CPU time Class P for jobs requiring lots of CPU time and run at some scheduled time Class E for jobs that run in the evenings only Class I for jobs to be run immediately A Class for jobs that use Tapes A Class for jobs that run CICS or IMS system programs and so on

16

Jobs in the Input queue further processing

contd..

After jobs get queued, the jobs JCL is:


converted into an internal text

scanned for syntax errors

JCL that is correct in syntax remains in the Input queue. JCL with errors goes to a different disk dataset called Output queue, which also contains the execution results of successfully executed jobs.

Input queue
E I

J E S

Output queue

BCP
17

Jobs in the Input queue Queue Entry

Each job in the input queue awaiting execution has the


an entry:
Job ID Job Name Job Class Priority

18

Jobs in the Input queue a screen shot

19

Jobs getting Executed Program Initiators


From the Input queue, jobs are picked for execution by the BCP using special programs called Program Initiators.

Program Initiators picks jobs for execution based on the jobs CLASS.

J E S
d
Input queue Initiators D 1 E 2 E 3 I 4 I P Output queue

BC P

20

Jobs getting Executed Initiators/Classes

contd

Each Initiator is governed by its own list of Job Classes based on which it preferentially picks jobs for execution from the input queue.

J E S
Input queue Initiators Class-List D 1 E E 2 PI E 3 IA I 4 F I P
Job ID

BC P

Output queue

Submit TSO //Job1 JOB .. //.. EXEC PGM=..

Redirect to other devices View / Purge Printer, Tapes, Disks

21

Jobs getting Executed Initiators - a screen shot

22

Jobs getting Executed Job completion contd..


The OS Notifies the user when the job completes.

J E S
Input queue E E P Output queue

BCP
NOTIFY (When done)

Job ID

Submit TSO //Job1 JOB .. //.. EXEC PGM=..

View / Purge

Printer, Tapes, Disks

23

Jobs in the Output queue


JES queues the Jobs Output in the output queue.
A jobs output comprises:

the Report about the job


which Initiator ran the job the CPU time taken by the job to run, among other

messages

the Programs output


Like the Payroll report

24

Jobs in the Output queue


The jobs outputs are queued based on the Print Classes:

Indicated by MSGCLASS on Job statement for Reports Indicated by SYSOUT on DD statement for Programs output Input queue Class A E

J E S

Output queue Print Class MsgClass Sysout

BCP

A B X or T

E
Job ID

Submit TSO //Job1 JOB .. //.. EXEC PGM=..

View / Purge

Redirect to other devices Printer, Tapes, Disks

25

Versions of JES
JES comes in two versions:

JES2 which most Mainframe computer systems use JES3 which are used by large networks of Mainframe computers

26

JES Control Statements


These are non-JCL statements that are used to communicate with JES.
They provide for instructions, the same way as JCL statements. A JCL statement to have the OS send you a Notification when your job completes execution:

//

JOB

Notify=TSO-UserID

27

JES Control Statements

contd..

Equivalent JES control statement:


/*Notify TSO-UserID // JOB //*Notify TSO-UserID JES2

JES3

//

JOB

d JES control statements look like: /* or //*JES Command ..

Based on the command, the JES control statements are coded before or after the JOB statement.

28

Chapter 2 Coding JCL

29

Coding JCL statements using TSO


You code JCL using TSO, Time sharing option.

A component of TSO called ISPF (Interactive System Productivity Facility) provides a full screen editor to create source program statements and JCL.

You use TSO to submit your jobs to the OS for processing.

You also use TSO to see the results after processing, using SDSF (Spool Display and Search Facility), a software product d you can access from TSO.

30

Coding JCL statements - Syntax


Syntax - A JCL statement has 5 fields:
1 3 10 12 71 72 80

ID Name
//DSRC012A //STEP010

Operation
JOB EXEC

Operands
NOTIFY=DSRC012 PGM=LM of program

Comments
The Job The Step

//DD1
//d

DD

DSN=Dataset name,Space=.,DISP=SHR,x

31

Coding JCL statements - Syntax


Syntax - A JCL statement has 5 fields:
1 3 10 12 71 72 80

ID Name
//DSRC012A //STEP010

Operation
JOB EXEC

Operands
NOTIFY=DSRC012 PGM=LM of program

Comments
The Job The Step

//DD1
//d

DD

DSN=Datasetname,Space=.,DISP=SHR,x

32

Coding JCL statements Identifier field


23 1

contd..

//DSRC012A //* The Step //STEP010

JOB EXEC

NOTIFY=DSRC062 PGM=LM of program

The Job..

//SYSIN
/*

DD

The DD..

Instream data //

d The Identifier field must be coded in columns 1, 2, 3 Identifies:

a JCL statement if

// /*

in columns 1 and 2 in columns 1 and 2

Comment statement / JES3 statement if


Delimiter statement / JES2 statement if

//* in columns 1, 2, 3

33

Coding JCL statements Name field


3 10

contd..

//DSRC012A //STEP010 //DD1

JOB EXEC DD

NOTIFY=DSRC012 PGM=LM of program DSN=Dataset name,

The Job The Step The DD

//

DISP=SHR

Name field must be coded in columns 3 through 10 d Names a JCL statement.


1 to 8 alpha-numeric (A-Z,0-9) or national characters (#, @, $). First character must be alphabetic or national. Must be followed by at least one blank space.

34

Coding JCL statements Operation field


12

contd..

//DSRC012A //STEP010 //DD1 //

JOB EXEC DD

NOTIFY=DSRC012 PGM=LM of program DSN=Dataset name, DISP=SHR

The Job The Step The DD

d Operation field must be coded from or after column 12 onwards It indicates the type of control statement (JOB, EXEC or DD).

Must be preceded and followed by at least one blank.

35

Coding JCL statements Operand field

contd..
71

//DSRC012A //STEP010 //DD1

JOB EXEC DD

NOTIFY=DSRC012 PGM=LM of program

The Job The Step

DSN=Dataset name,DISP=SHR

//

d The Operand (Parameter) field follows the operation field


Contains one or more parameters separated by commas


No blanks between the parameters

Parameters can be coded up to column 71

36

Coding JCL statements Comment field


//DSRC012A //STEP010 JOB EXEC DD NOTIFY=DSRC012 PGM=LM of program

contd..
71

The Job.. The Step..

//* The DD.


//DD1 DSN=Dataset name,DISP=SHR

The Comment field can be coded after the operand field, up to column 71 d

It contains documentation on the JCL statement

Must not be used unless there is an operand field and must follow the operand field Must be preceded by at least one blank

Note : The Comment field is different from Comment statement (//*); though they both serve to code comments.

37

Coding JCL statements - Continuation of Statements Continuation of the Parameter field on to the next line

If you interrupt the field including the comma before column 71


16 71

//DD1 //

DD

DSN=Dataset name,Space=(TRKk,(1,1)), DISP=SHR,DCB=.

If you interrupt the field including the comma at column 71


16 71 72

d
//DD1 DD

DSN=Dataset name,Space=.,DISP=SHR,x

//

DCB=..

38

Chapter 3 -The JOB statement

39

The JOB statement


Syntax:
//Jobname JOB <Positional Parameters>,<Keyword parameters>

Purpose

Marks the beginning of a work load (job) to the OS. Supplies the necessary information and instructions to the OS
Gives the job a name Instructs the OS the importance of the job relative to other

jobs
Informs who will pay for the CPU time the job uses

Instructs where the jobs reports must be sent

40

The Job statement a detailed look


//Jobname Mandatory. Usually your TSO userid followed by one character. JOB <Positional Parameters>,<Keyword parameters> Accounting information,
NOTIFY,CLASS,PRTY,

Programmers name.

MSGCLASS,MSGLEVEL,
RESTART,TIME, TYPRUN ADDRSPC, REGION among others.

d Example:
//DSRC012A // JOB (012,John), NOTIFY=DSRC012,CLASS=A,PRTY=15, MSGCLASS=T,MSGLEVEL=(1,1)

41

Positional and Keyword parameters


//Jobname JOB <Positional Parameters>,<Keyword parameters>
Acct. Info.,Prog.name CLASS=..,NOTIFY=.

Positional parameters

Must precede keyword parameters

Within a list of parameters, must be in specific positions separated by commas


Absence of first parameter in a list must be indicated by a comma

Keyword parameters

Must follow positional parameters Within a list, can be coded in any position Absence within a list need not be indicated by comma

42

The Job statement ACCOUNTING INFORMATION


Identifies your job for accounting or billing purposes; say to bill for the CPU time used by your job. Format is installation dependent. Optional

Example :
//DSRC012A JOB (012)

d Additional accounting information can be given (installation dependant):


//DSRC012A JOB (012,1)

43

The Job statement PROGRAMMERS NAME


Identifies the user ie. you or, the kind of Job.
Format is installation dependent. Specified in apostrophes if the programmers name parameter contains spaces or special characters, other than the period or hyphen. Optional

Example : d //DSRC012A JOB (012,1),JOHN


//DSRC012A JOB (012,JOHN,CICS),PROD CICS

44

The Job statement - CLASS


Queues jobs for execution based on the importance of the

job. The importance in turn depends on the type of the job:


A job involving complex statistical calculations Is a type of job taking a lot of CPU time and to be run in the

night only A job updating a database Is a type of job which is I/O bound and to be run immediately
A job generating reports

Is a type of job to be run in the evenings

A job running system programs


Is a type of job to be run continuously

45

The Job statement CLASS


A Job is assigned a CLASS based on its type
JOB 1 2 3 CLASS E P O

contd..

CLASS is represented by a single alphanumeric character (A-Z,0-9); fixed by the installation.


CLASS=E CLASS=9 may imply type which is run in the evenings may imply a job that runs at a specific time

d Example :
//DSRC012A

of the day

JOB

(012,John), NOTIFY=DSRC012,CLASS=E

CLASS gives jobs a preference for execution by the OS.

46

The Job statement CLASS

contd..

Operator can change the CLASS even after the job is submitted.

Operator can also reconfigure Initiators to pick Classes other than what the initiator was originally configured to pick.

47

The Job statement PRTY


Syntax for Priority.
Determines scheduling the jobs belonging to the same CLASS.
JOB 1 2 CLASS E E PRTY 1 13

48

The Job statement PRTY


PRTY ranges from values

contd..

0 to 15 if JES2 is used 15 being the highest priority.


0-14 in JES3 is used 14 being the highest priority.

dExample: //DSRC012A //DSRC012B

JOB JOB

CLASS=E,PRTY=1 CLASS=E,PRTY=15

49

The Job statement PRTY

contd..

If jobs wait in the queue under the same CLASS and same PRTY, then the jobs are picked for execution based on FIFO.
JOB 1 2 3 CLASS E E E PRTY 1 13 13

50

The Job statement DPRTY


Syntax for Dispatching Priority
Sets priority for CPU allocation to jobs that are running

Your job can get the CPU prior to the other jobs.

51

The Job statement - TIME


Establishes a CPU time limit for a job to execute all its steps. Syntax is TIME=(MINUTES,SECONDS)

Minutes range from 1 through 357912 (248.55 days) Seconds range from 1 through 59
implies maximum CPU time for this JOB is 1minute and 30 seconds.

TIME=(1,30)

System will abend the job with a system completion code of 322, if the specified TIME is exceeded.

52

The Job statement TIME


Reasons to code TIME

contd..

While testing a new program which may go into a loop, unless it is timed out automatically (system code 522)

Special jobs which need to by-pass any TIME limit barrier and which must not be timed out too
Syntax of TIME=1440 or NOLIMIT takes off any CPU time limit

and lets the job run continuously. This job will not be timed out.

Syntax of TIME=MAXIMUM permits maximum CPU time for a job - 357912 minutes.

53

The Job statement TIME


Examples:
TIME=2 TIME=(,2) //DSRC012A

contd..

maximum CPU time for this JOB is 2 minutes maximum CPU time allowed is 2 seconds JOB NOTIFY=DSRC012,TIME=(,50)

54

The Job statement - REGION


Specifies the amount of virtual storage a job can use
Every step within the job gets that amount of storage as requested vide the REGION parameter

Can be specified in kilobytes(K) or Megabytes(M)

Syntax is REGION=nK

n ranges from 1K to 2096128K

nM

n ranges from 1M to 2047M

d If not coded, a system default or installation defined The system allocates the storage above and below the 16 MB line Example:
//DSRC012A //DSRC012A JOB JOB REGION=4092K same as coding REGION=4M

55

The Job statement REGION

contd

If the job requires more storage than what it requests, the system returns a completion code of 804 or 80A.

56

The Job statement - ADDRSPC


Syntax for Address space Prohibits or allows a job (its steps) from being paged Syntax is ADDRSPC=REAL or VIRT (Virtual)

REAL locks the job in central storage during execution VIRT, the default, lets the job be paged

d Do not use REAL as it will reduce system performance

Use REAL only for time-dependant programs and those that dynamically modify channel programs during I/O operations.

Example:
//DSRC012A JOB ADDRSPC=REAL

57

The Job statement - NOTIFY

Requests that the OS sends a message about: the Jobs completion and
its completion status whether normal or abnormal

Code NOTIFY=your TSO userID, if you want the


system to notify you the above messages.
dExample :
//DSRC012A JOB (012,John), NOTIFY=DSRC012

58

The Job statement NOTIFY

contd..

The OS giving your job a number (JobID) when submitted.

59

The Job statement-NOTIFYa screen shot contd..


Notification about completion and completion status.

60

The Job statement NOTIFY


Omitting this parameter may result in you seeing the
OS giving your job, a number (JobID) when submitted but not its completion and completion status.

contd

To notify someone (userid) not at the jobs origin, code the JES2 NOTIFY node control statement
Example: /*NOTIFY node.TSOuserid
//DSRC012A JOB CLASS=E,<other parameters>

d
Code NOTIFY=&SYSUID, if you share your JCL and want that user submitting your JCL to get notified Users need not change your code the NOTIFY value

61

The Job statement - MSGCLASS


Syntax for Message Class
After the job run, directs the Reporting messages of the OS to

disk areas or printers


Reports usually held in the output queue without printing, for viewing vide

TSO.

The reporting messages (commonly called printed output)

include:
The JES2 JOB LOG stating whether the job was run

when the job started and stopped

which initiator picked the job for execution

the JES2 JOB STATISTICS comprising


the date of job run the number of lines of JCL code (cards) read by the OS

the JCL submitted is listed (with the JCL statements numbered by the OS).

62

The Job statement MSGCLASS


the ALLOCATION messages stating

contd

the I/O devices and datasets allocated for each job step
memory allocated for each step the CPU time taken to execute each step a completion code - COND CODE/ System completion code, which

communicates whether the step executed successfully or not.


the disposition of the datasets after the step executed

The final messages states the CPU time taken to run the entire job

(all steps).

63

The Job statement MSGCLASS


character (A-Z,0-9); fixed by the installation.
MSGCLASS=T

contd..

MSGCLASS is represented by a single alphanumeric


may hold messages in the output queue for viewing from TSO and purged by the user after some specific time frame MSGCLASS=A MSGCLASS=D may route messages directly to a printer may hold messages in the output queue for viewing

from TSO and purged automatically by the system

after some time.

If not coded, defaults to installation standards.

Example:
//DSRC012A JOB CLASS=E,MSGCLASS=T

64

The Job statement - MSGLEVEL


Syntax for Message Level.
Determines the amount of JCL and Allocation messages to be directed to the device indicated in MSGCLASS

Syntax is MSGLEVEL=(JCL,Allocations)
d JCL - takes values 0 or 1 or 2
0 1 2

print only JOB statement print all user-coded JCL plus procedure JCL statements print only user-coded JCL statements

65

The Job statement MSGLEVEL

contd..

Allocations - takes values 0 or 1


0 1

print all the allocation messages only if the job ends abnormally print all the allocation messages whether the job ends normally or abnormally

Default MSGLEVEL=(1,1)
Example:
//DSRC012A JOB MSGCLASS=T,MSGLEVEL=(1,0)

66

The Job statement - TYPRUN


Syntax for Type Run. Prevents job run

to give your JCL a syntax check or to hold your job for later execution

To give your JCL a syntax check use TYPRUN=SCAN


SCAN causes your JCL to be checked for coding errors. The coding errors comprise:
mis-spelled and misplaced parameters Invalid characters Unbalanced parantheses

Your job does not run; resources are not allocated. The syntax error messages are routed to the output queue and can be viewed.

67

The Job statement TYPRUN

contd..

To hold your job for later run, use TYPRUN=HOLD


HOLD causes your job to remain in the input queue without going in for execution until explicitly RELEASEd by the operator for execution; this provided your JCL is syntactically correct.

If incorrect, your job gets routed to the output queue.

To print your JCL to a printer without running the job use TYPRUN=COPY; ensure you assign a printer class to MSGCLASS
Example:

d //DSRC012A

JOB

NOTIFY=DSRC012,TYPRUN=SCAN

To make your job run, do not code TYPRUN

68

The Job statement - RESTART

Enables continuing running of a previously aborted job


Specifies a starting Step for the new job run
RESTART=STEPNAME

Syntax is
Example:

//DSRC012A d //STEP1 // //STEP2 //

JOB EXEC

RESTART=STEP2 PGM=LM of one program

EXEC

PGM=LM of another program

69

Chapter 4 - The EXEC statement

70

The EXEC Statement


Syntax :
//Stepname EXEC <Positional Parameters>,<Keyword parameters>

Purpose

Names the EXEC statement Mainly identifies the:


Program to execute (PGM=LM of the program)
Procedure to execute (PROC=Name of the Proc)

(Certain programs like the language compilers which perform the same function for all its users, are converted to a form called PROCEDURES)

71

The EXEC statement a detailed look


//Stepname EXEC <Positional Parameters>,<Keyword parameters> PGM or PROC PARM, COND, TIME, REGION

Optional, but useful for referbacks and locating errors in the jobs reports

//Step010 //DDIN

EXEC DD EXEC

PGM=Load Module of a Program, Time=(,5) . PROC=Procedure Name Procedure name (or)

//Step020

//Step030

EXEC

PGM=LM of another program

72

The EXEC Statement - PGM / PROC


Syntax for Program / Procedure
PGM = Load Module Of User-written Application program. For load modules in user-load libraries, JOBLIB or STEPLIB must be coded. PGM = Load module of Utility Program. Stored in system library, SYS1.LINKLIB. Eg. SORT utility

PROC = Procedure Name. Stored in system library SYS1.PROCLIB.


For PROCs in user-libraries, JCLLIB must be coded.

73

The EXEC Statement - PGM / PROC


Upto 255 steps can be under one JOB

contd..

If the load module is not found, the system will abend the step giving a completion code of 806.
Example:
//DSRC012A JOB
EXEC EXEC EXEC

NOTIFY=DSRC012
PGM=Load Module of Your Program PGM=SORT (the LM of Utility Program) PROC=Procedure Name

d //STEP1
//......... //STEP2 //............. //STEP3

74

The EXEC Statement - COND


Syntax for Condition. COND defines the conditions under which the OS must execute a step. Also called Return code.
EXAMPLE:
//Cobol EXEC
EXEC

PGM=Igycrctl
PGM=Hewl,COND=(4,LT,COBOL)

d //..
//Lked

Interpretation: If Condition is satisfied, Do Not Execute the Step If Condition is not satisfied, Execute the step.

75

The EXEC Statement - COND


The Compile/Link-edit JCL:

contd..

//LKED EXEC PGM=HEWL,COND=(4,LT,COBOL)

This condition tells the OS that If 4 is less than the value of the condition code of the compiler step, then, shut off the execution of the link-edit program. This will be true if the d compiler sets its condition code to 0005 or greater.

76

The EXEC Statement - COND


COND can be used for two reasons:

contd..

To define conditions under which you want a step of a normally executing job to be shut off. You code this in the form COND = (4,LT,StepName) or COND=(4,LT)

To tell the OS to process a step even if a previous step in the job has already abended, or, only if a previous step abended. Ordinarily, the OS would throw out the whole job when a step abends and ignore all steps that follow. You code this in the form COND=EVEN or COND=ONLY.

77

The EXEC Statement - COND


Syntax in Normal Mode :

contd..

COND=(Condition code value,Comparison operator,Stepname) COND=(Condition code value, Comparison operator) Condition code value - 0 to 4095.

Comparison operator - GT, LT, GE, LE, EQ, NE

d Syntax in Abnormal Mode :


COND=EVEN COND=ONLY

78

The EXEC Statement - COND

contd..

Condition code values in the range 0 to 4095 leaves a job still in the normal mode, not the abnormal mode. Abnormal mode (or Abend) is indicated by a three position hexadecimal value:
806 Load module not found

80A
d OC7

Inadequate Central storage (Region)


Data exception

79

The EXEC Statement - COND

contd..

Condition code values range from 0 to 4095.


Any program that you execute, be it a utility program like the language compiler, or your program, leaves a number in this range. This number termed the Condition code (CC) is also called the Return code (RC).
Conventional condition code values for IBM supplied

compilers and utility programs:

CC 0000 Program execution was completely successful CC 0004 Execution was OK but caused warning messages CC 0008 Program execution was seriously flawed

CC 0012 Program execution was very seriously flawed


CC 0016 Program failed disastrously

80

The EXEC Statement - COND


programming language: PL/I C COBOL CALL PLIRETC(Value); EXIT(Value); MOVE <Value> to RETURN-CODE MOVE <File status> to Return-Code.

contd..

Condition code values for your programs depends on the

81

The EXEC Statement - COND


//Step010 Exec Pgm=A1111

contd..

//Step020 Exec Pgm=B2222,Cond=(0,LT,Step010) Pgm B2222 is not executed if pgm A1111 returns any CC > 0000 //Step030 Exec Pgm=C3333,Cond=(0,Eq,Step010) Pgm C3333 is not executed if pgm A1111 returns CC 0000

//Step040 Exec Pgm=D4444,Cond=(4,Eq)


Pgm D4444 is not executed if pgm A1111 or pgm B2222 or pgm C3333 returns CC 0004

82

The EXEC Statement - COND


//Step010 Exec Pgm=Pgm1
//Step020 Exec Pgm=Pgm2 //Step030 Exec Pgm=Pgm3, // Cond=(4,Eq,Step020) //Step040 Exec Pgm=Pgm4,Cond=Even //Step050 Exec Pgm=Pgm5,Cond=Only

contd..

CC 0000
CC 0004 Step not run because of CC CC 0004 Step not run due to Cond=Only

//Step060 Exec Pgm=Pgm6

Abend SoC7
Execution blocked by Abend

d //Step070 Exec Pgm=Pgm7


//Step080 Exec Pgm=Pgm8,Cond=Only
//Step090 Exec Pgm=Pgm9,Cond=Even

CC 0000
CC 0000

Cond=Even and only

//Step100 Exec Pgm=Pgm10,Cond=Even Step executed

83

The EXEC Statement - COND


//STEP1 EXEC PGM=READ,COND=((4,GT),(6,LT))

contd..

The step is executed for CC 4,5 and 6 and not for 0 to 3,7 and

above.
Note : The OS always wants to by-pass steps to lessen its work.

84

The EXEC Statement - COND

contd..

A maximum of 8 conditions may be checked in any one step (EVEN & ONLY count as one)
Omitting stepname in the condition, will apply the test to all preceding steps If one of the steps being checked was not executed, its condition check is ignored

d
If a Condition is not coded for a step and its previous step abends, then this step is by-passed.

85

The EXEC Statement - COND

contd..

Whatever the Condition coded, the system bypasses subsequent steps when :

a JCL error is encountered (syntax error,datasets not found) Datasets allocation error Job enters an Abend mode, unless Cond=Even or Only is coded Operator cancels the job

86

The If/Then/Else/EndIf Statement


This construct is an alternative to coding COND; introduced in OS390. Allows the outcome of one STEP to determine the execution of subsequent steps.
EXAMPLE: d// IF (STEP040.RC EQ 4) THEN //STEP050 EXEC PGM=LM of a program // ELSE //STEP060 EXEC PGM=LM of another program // ENDIF

87

The If/Then/Else/EndIf Statement


Syntax:
//Name IF (Relational expression) THEN

contd

// Steps to processed when relational expression is true

//Name ELSE
// Step to processed when relational expression is false //Name ENDIF d

Name field is optional. Operation fields are IF,THEN, ELSE and ENDIF.
ELSE is an optional clause. ENDIF marks the end of the statement.

88

The If/Then/Else/EndIf Statement

contd

Relational expression field consists of:


Comparison operators - GT, LT, NG, NL, EQ, NE, GE, LE

>
Connect operators - AND, OR

< > < I

= >= <=

&

NOT () operators
Keywords:

RC ABEND ABEND ABENDCC RUN RUN Examples: // IF (RC > 8

Indicates Return code Indicates occurrence of Abend Indicates non occurrence of Abend Indicates a specific system or user abend code Indicates execution of the specified Step Indicates non execution of the specified step & Step020.RUN) THEN..

// IF (Step020.RC > 8) THEN..

89

The If/Then/Else/EndIf Statement


RC

contd

Indicates that the relational expression tests a Return Code. Code (stepname.RC, a comparison operator, a RC value) or code (RC, a comparison operator, a RC value)

IF (Step040.RC EQ 4) THEN ..
RC values range from 0 to 4095 since this is the syntax in normal mode. ABEND or (ABEND EQ TRUE)

d Indicates that the relational expression tests for an Abend condition


that occurred in the job prior to the time of evaluation IF ABEND THEN.. tests true when an abend occurred in any previous step.

90

The If/Then/Else/EndIf Statement


(ABENDCC EQ Sxxx) or (ABENDCC EQ Uxxxx)
Indicates that the relational expression tests for:

contd

System completion code (S followed by hexadecimal value of 3 digits) User defined completion code ( U followed by decimal value of 4 digits) IF (ABENDCC EQ SOC4) THEN IF (ABENDCC EQ U0100) THEN.. (Stepname.RUN) or (Stepname.RUN EQ TRUE) stepname) has been executed.

d Indicates that the relational expression tests that the specified step (vide

91

The If/Then/Else/EndIf Statement


EXAMPLES:
// IF (RC > 8 // IF (RC = 8 & I RC < 16) THEN.. RC = 12 I RC > 24) THEN.

contd

// IF (RC > 8) THEN..

Use parantheses in compound expressions to make the system evaluate the relational expression in the order in which you want; else, the order of evaluation will be: d First the NOT operator followed by

Comparison operator and then the Connect operator


IF STEP6.RC EQ 1 AND ((STEP7.RC STEP8.RC EQ 1) OR STEP9.RC EQ EQ 4 OR 4) THEN .

// //

92

The If/Then/Else/EndIf Statement

// // //

contd

You can nest IF/THEN. statements up to 15 levels.


IF NOT (STEP1.RC EQ 1 AND STEP2.RC EQ 1) THEN IF (STEP4.RC LE EXEC EXEC ELSE PGM=Program TEN 4 AND STEP1.ABEND) THEN PGM=Program ONE

//STEP060 //STEP070

//

ENDIF
EXEC PGM=Program TWO

// d ELSE //STEP080 // ENDIF

93

The EXEC Statement - TIME


Establishes a CPU time limit for a program to execute.
If the time limit is exceeded, the system abends the step with a completion code of 322. If not coded, the Time parameter takes a value that is installation defined. d

94

The EXEC Statement - TIME

contd..

If you specify time both in the JOB and EXEC statement, then the time parameter on the EXEC applies for that step and the remaining time limit from the JOB statement is available to the other steps.
//DSRC012A //Step1 //Step2 JOB EXEC EXEC TIME=(1,50) PGM=PROGRAM1,TIME=(0,30) PGM=PROGRAM2

d
//DSRC012A JOB TIME=(1,50)

//Step1
//Step2

EXEC
EXEC

PGM=PROGRAM1,TIME=(1,50)
PGM=PROGRAM2

95

The EXEC Statement - TIME

contd..

The limit on the JOB totals to the CPU time usage of all the steps.
//DSRC012A
//Step1 //Step2

JOB
EXEC EXEC

TIME=(1,50)
PGM=PROGRAM1,TIME=(1,50) PGM=PROGRAM2,TIME=(1)

dNote: The OS ignores any limit on the EXEC which is larger than that
coded on the JOB statement.

96

The EXEC Statement - REGION


The Region parameter specifies the amount of virtual storage which the program (step) can use.
Can be specified in kilobytes(K) or Megabytes(M). Format :
//Step1
//Step2

Region=nK or nM
EXEC
EXEC

PGM=SORT,REGION=5M
PGM=Load Module,REGION=3M

d//.
//...

97

The EXEC Statement - REGION

contd

If REGION is coded on the JOB and EXEC, then the JOB limit overrides any REGION that is larger
//DSRC012A //Step1 //. JOB NOTIFY=DSRC012,REGION=2M
Each step gets only 2M of storage

EXEC

PGM=SORT,REGION=5M

//Step2

EXEC

PGM=Load Module,REGION=3M

//...

IF no REGION is coded, system default value or installationd defined default. If a program requires more storage than coded, step fails with a system completion code of 804 or 80A.

98

The EXEC Statement - PARM


Syntax for Parameter.
Passes data to the load module that is being executed. A maximum of 100 bytes of data can be passed.

The passed data can be: d received by the program - through the programs Linkage section and used in the program - if Procedure division using Linkage sections data- area is coded. 99

The EXEC Statement - PARM


Example :
1) Pass data vide PARM in the JCL:

contd

//STEP010 EXEC PGM=Load Module,PARM=001 JOHN 2) Access the data in a Cobol program: IDENTIFICATION DIVISION. DATA DIVISION.

LINKAGE SECTION.

d01 PARM-DATA-AREA.
05 PARM-LEN PIC S9(4) COMP.

05 PARM-DATA1.
10 DATA1-IN X(100). PROCEDURE DIVISION USING PARM-DATA-AREA. DISPLAY DATA1-IN.

100

The EXEC Statement PARM


Coding Rules:

contd

Use apostrophes around the passed data if the data consists of a space
PARM=001 JOHN

If passed data comprises an apostrophe or an ampersand, code two such characters consecutively.
PARM=Hello World PARM=ABC&&4

To continue coding data on the next line, code a comma and continue. Also coding apostrophes around continued data is a must. Comma gets included in the byte count.
PARM=001,
JOHN

To code till column 71 and then continue, leave column 72 blank and continue on the next line from column 4 through 16

101

Chapter 5 - The DD statement

102

The DD statement
DD stands for Data definition.
Defines to the OS, information about the Dataset(s) which the executing program uses:
//. //.. JOB EXEC . PGM=LM of a program

//DDname1

DD
DD

<Information about the dataset which the


above program uses> do..

//DDname2

103

The DD Statement

contd..

The Information supplied, depends on whether the program:


Reads from the dataset(s) or Writes into an existing dataset(s)
//DDRd //

DD

DSN=<Name of the dataset>, DISP=..

Prints the dataset(s)


//DDPrt DD SYSOUT=

Creates new dataset(s)


//DDCrte
// //

DD

DSN=<name of the dataset>,


DISP=<whether the dataset is new or existing>, UNIT=<whether the dataset is to be stored on Disk or Tape>,

//
//

SPACE=<amount of disk-storage space required>,


DCB=<information about how the data is to be stored>

104

The DD Statement

contd..

Up to 3273 DD statements can be defined in a single Step.


//. //.. //DDname1 //DDname2 //DDname3 JOB EXEC DD DD DD . PGM=LM of a program <Information about the dataset which the above program uses> do.. do..

105

What is a Dataset ?
A store of data Employee data, Customer data.
Each entitys data (Employee say) is called a RECORD. Many such records form the Dataset. Types of Datasets used in Mainframes today :
Broadly based on arrangement of records inside the dataset -

d Physical sequential (PS)


DSRC012.Empdata DSRC012.Empdata(Member1)

Partitioned sequential (PDS)

VSAM type (Sequential, Indexed, Relative) DSRC012.BaseCluster

106

The Disk Volume Table of contents - VTOC


A Disk Volume is an assembly of magnetic platters which
provides millions of bytes of storage.

Each disk volume has a unique name called Volume Serial number.

107

The Disk Volume Table of contents

contd..

Recorded on each disk volume is the VTOC which is a dataset to keep track of all datasets stored on that volume.

The VTOC is one level above the level of PDS directory.

108

The SYSTEM CATALOG


Highest level of information above the level of VTOC.
The system catalog is a critical dataset on a special disk volume and contains information on where (on which disk volume) each dataset is stored.
Dataset Name DSRC012.COBOL.PGMS DSRC012.JCL.PGMS Location (name of the Volume) ZTSO03 ZTSO01

109

The SYSTEM CATALOG

contd..

Use TSO to view the System Catalog.

110

The DD Statement - a detailed look


//DDname DD <Positional parameters>,<Keyword parameters>

Mandatory. If omitted, the dataset is concatenated with the one defined in the previous DD statement.

*
Data Dummy or NullFile

Dsn, Disp, Unit,

Volume,
Space, Dcb Sysout

111

The DD statement - *
Marks the beginning of Instream data to a load module.

Can be compared to passing data to a load module using the PARM parameter on the EXEC statement.

Format :
//STEP010 EXEC DD PGM=LM of a program *

d //DDname
/*

<..Instream data..>

112

The DD statement - *

contd..

Instream data to a Cobol program:


In the JCL:

//STEP010 EXEC //SYSIN DD 001 JOHN .. /*


In the Cobol program:

PGM=LM of a Cobol program *

IDENTIFICATION DIVISION. DATA DIVISION. WORKING-STORGAE SECTION. 77 DATA1-IN PIC X(80). PROCEDURE DIVISION. ACCEPT DATA1-IN.

The load module can be User-written program or


Utility program.

113

The DD statement - *

contd..

Instream data to Utility programs:


//STEP010 EXEC PGM=SORT // // //SYSIN DD * SORT FIELDS= /*

The end of data is indicated by the delimiter - /* The instream cannot contain // as data in columns 1,2 when * is used.

114

The DD statement - DATA


DATA is functionally the same as * operand, except that instream data can contain // in columns 1,2
//STEPNAME
//DDname

EXEC
DD

PGM=LM of a program
DATA

Instream data.. Instream data. /* d

115

The DD statement-Delimiter for Instream data


What if instream data consists of /* in columns 1 & 2 and, /* is used to delimit the instream data too ?
//SYSIN /*abc.. /* DD DATA

Under such situations delimit vide the DLM parameter which indicates the new delimiter to be used. DLM can be used for * and DATA
//SYSIN /*abc.. $$ DD DATA, DLM=$$

116

The DD statement - DUMMY / NULLFILE


DUMMY assigns a dummied status to a dataset:

Any I/O requests on the dataset is bypassed No devices and space is allocated to the dataset

117

The DD statement - Dummy / Nullfile


WHY DUMMY ?

contd..

Used to test a program flow without actually processing the dataset


An attempt to read a dummied dataset results in an EOF exit; A write request in the program is ignored.

For Utility programs, used to cut-off control statements (instream data) to the program

//Step1 // //SYSIN

EXEC
DD

PGM=IEBGENER
DUMMY

Any unwanted outputs listings can be suppressed.


Note: The other syntax is to code DSN=NULLFILE.

118

The DD statement - Keyword Parameters


If data is to be accessed from Disk or Tape, the parameters are:

DSN - Dataset Name - DSRC012.ITC.PGMS. DISP - Status of the dataset - New or Existing. UNIT - Hardware device where the dataset resides Disk or Tape. VOL - Identification of the disk or tape. SPACE - Amount of space required by the dataset on the disk. DCB - Data Control Block information of the dataset.

//DDname

DD

DSN=<Dataset name>,
DISP=SHR

//

If data is to be sent to Terminal or Printer:


SYSOUT parameter; none of the above. //DDname DD SYSOUT=<Terminal>

119

The DD statement - DSN


Syntax for Dataset Name
Names the full qualified name of the physical dataset used by the load module. Dataset name is maximum 44 characters long with a period after every 8 characters (or less). Maximum d length is inclusive of period.

120

The DD statement - DSN


contd..

Classified into Permanent and Temporary datasets


Permanent datasets are used as a data-store on disks and tapes.

Temporary datasets are used as work areas within a job; they last only for the duration of the job. A Temporary dataset name starts with && followed by 1 to 6 characters - DSN=&&TEMPRY
Absence of DSN coding also denotes a temporary dataset.

A DSN coding without && indicates a Permanent dataset.

121

The DD statement - DSN


Code for Permanent dataset:
//DD8 DD

contd..

DSN=DSRC12.EMP.DEVL

Code for Temporary dataset:


//DD8 DD DSN=&&TEMP

If the dataset (DSN) is not found in the system catalog, the system throws a JCL error. d Dataset names (DSN) cannot be duplicated in the VTOC. If duplicated, the system returns a CC of 8.

122

The DD statement DISP (Status)


Syntax for Disposition.
DISP=({Status}{,Normal-disposition}{,Abnormal-disposition})

Status specifies the existence of a dataset at the start of the step (not start of the job) - whether NEW, OLD, MOD, SHR
NEW specifies that the dataset is new and does not exist when the

step begins.
OLD specifies that the dataset exists when the step begins.

Gains exclusive control of the dataset for the duration

of the step and safeguards against concurrent access to the

dataset. Over-writes existing data.


MOD Extends the dataset (if existing) or creates a new one (if not

existing). Gains exclusive control of the dataset.


SHR specifies that the dataset can be shared with other jobs

during the step.

123

The DD statement - DISP(Normal termination)

contd..

Normal termination disposition specifies what the OS must do to the dataset if the step terminates normally whether to CATLG, UNCATLG, PASS, KEEP, DELETE
CATLG specifies that the OS must record information about the

dataset like its Name, its Unit, Volume identifier in the system catalog when it is newly created or, update the entry if existing. You cannot catalog a temporary dataset.
KEEP specifies to the OS that newly created datasets need not have a catalog entry but just be retained on the volume.

UNCATLG specifies that the OS removes all entries from the catalog, but retain the dataset on the volume.
PASS specifies to the OS that subsequent steps will access the dataset and that the dataset need not be cataloged (if new) or the

catalog entry need not be updated (if existing). Can PASS PS and PDS but not VSAM datasets. Common to code DISP=(NEW,PASS) when you create a temporary dataset.
DELETE specfies to the OS that the dataset must be uncataloged and deleted from the system when the step ends normally. 124

The DD statement- DISP(Abnormal termination) contd..

Abnormal termination disposition specifies what to do with the dataset when the step terminates abnormally - whether CATLG, UNCATLG, KEEP, DELETE.

Note: For SMS managed datasets, KEEP always reverts to CATLG, since all SMS managed datasets must be cataloged.

125

The DD statement DISP


PDS and DISP

contd..

To create a new member of an existing PDS, code DISP=OLD or SHR, not NEW, since DISP refers to the partitioned dataset as a whole not to the member. The PDS directory is updated to know about the new member. VSAM datasets and DISP

Code DISP=OLD or SHR only for DD statements that access a VSAM dataset. d

126

The DD statement DISP (Defaults)


DISP Coded as : Defaults to :

contd..

If DISP parameters are not coded, the following defaults:


If not coded .(NEW,DELETE,DELETE) (OLD)...(OLD,KEEP,KEEP) (SHR)(SHR,KEEP,KEEP) (,CATLG).(NEW,CATLG,CATLG) (MOD).. If dataset does not exist : (NEW,DELETE,DELETE) If dataset exists : (OLD,KEEP,KEEP) (MOD,CATLG,)..(NEW/OLD,CATLG,)

DELETE)
to append records, code MOD.

DELETE)

Disposition of OLD deletes existing records from the dataset. So,

127

The DD statement - UNIT


UNIT requests the type of device - Disk or Tape, required to store a dataset.
SYNTAX : UNIT=Hardware address (or) Device Model number 3390 SYSDA VIO 0C4

(or)

Symbolic device Group name (or) Virtual Input / Output

128

The DD statement UNIT


EXAMPLES:
//DDN // // DD

contd..

DSN=DSRC012.New.DS, DISP=(NEW,CATLG,DELETE), UNIT=3390


Implies a disk drive based on Model number

//DDB

DD

DSN=.

//

UNIT=3480

Implies a tape drive based on Model number

Note: System Catalog entry may state DEVICE instead of


UNIT.

129

The DD statement UNIT(Hardware Address) contd..


Hardware Address

Every I/O device (Disk drive, Tape drive, Printer, Terminal) has a unique label called Hardware Address The OS communicates with these devices using their addresses You can specify where to store your dataset using these Addresses, represented by three hexadecimal characters D5A, A58, 0C4. EXAMPLE:
//DD8 DD DSN=DSRC012.New.DS,

//
//

DISP=(NEW,CATLG,DELETE),
UNIT=A58

130

The DD statement UNIT (Model Number)


Device Model number

contd..

IBM convention for every item it manufactures Disks carry Model Numbers like 3390, 3380 Tapes carry numbers like 3490, 3480. Printers and all other I/O devices carry an IBM convention. The OS maintains a list of addresses for each Model number.

d EXAMPLE:
//DD8 // // DD DSN=DSRC012.New.DS, DISP=(NEW,CATLG,DELETE), UNIT=3390

131

The DD statement UNIT (Group Name) contd..


Symbolic Group name

Installations group hardware addresses of similar devices destined for a specific purpose (production-preferred high speed disk drives, or drives to store test datasets) and give a unique name to each group. Say, addresses of disk drives for some specific purpose are listed under a group named SYSDA. The OS selects any available disk from the group list SYSDA, to store the dataset. //DD8 // // DD DSN=DSRC012.New.DS, DISP=(NEW,CATLG,DELETE), UNIT=SYSDA

Symbolic names facilitates smooth phasing-in of newly added devices, by adding their addresses to a group list. (The JCL code need not be changed). 132

The DD statement UNIT (VIO)


Virtual Input / Output

contd..

Represents the storage disk that the OS uses for its virtual storage operations.
//DD8 // // DD DSN=DSRC012.New.DS, DISP=(NEW,CATLG,DELETE), UNIT=VIO

VIO used to store:

Work datasets, as in a compiler program

d Temporary datasets, used within a job


Cannot retain the datasets in VIO permanently.

Lasts only for the duration of the job.

133

The DD statement - UNIT (Volumes)

contd..

Along with UNIT, we can specify the number and name of the VOLUME of that Unit required.

VOLUME is the name of a specific UNIT. One unit can have many volumes. Say, a disk unit 3390 can have many volumes named Pack01, Pack02. And a tape unit can have many volumes named 038272, 013267, 020133.
Syntax:

d UNIT=(3390,2),VOL=SER=(PACK01,PACK02)
where PACK01 and PACK02 are the names of the two volumes of 3390 disk unit.

For SYSDA, Volume is not applicable. The OS selects any available disk from the list SYSDA.

134

The DD statement - UNIT

contd..

Code UNIT only for New and existing Uncataloged datasets.

(Unit need not be coded for existing Cataloged datasets since the OS can locate the dataset from the System Catalog).
If your dataset is to be sent to a Printer or Terminal, code SYSOUT instead of UNIT.

135

The DD statement - UNIT

contd..

While creating New datasets, if UNIT is not coded:


Defaults to installation-defined devices based on purpose: Unit Volume

For Development datasets


For Testing datasets

3390
3391

ZTSO01
ZRSO06

For SMS managed datasets, defaults to STORAGE CLASS: Storage Class SCTSO Unit 3390 Volume ZTSO03

136

The DD statement- UNIT (Common problems)


Common problems with UNIT

contd..

If you forget to code DISP at the dataset that you are reading, //DDRd DD DSN=DSRC012.OLD.DS

you will get an error message SPACE NOT SPECIFIED FOR DATASET or INCORRECT DEVICE TYPE SPECIFIED.

d
Correct this problem by coding DISP=SHR that you forgot, not UNIT. You will get this same error message if you code an incorrect UNIT with a Cataloged dataset.

137

The DD statement - SPACE


Specifies how much space to allocate for a new disk dataset.
Disk is often called DASD in the mainframe environment. Syntax: SPACE=(S1,(S2,S3,S4),S5)

S1 - the Unit of space in Cylinders(CYL),Tracks(TRK), Blocks of records(a number representing block size), Record length S2 Primary (initial) quantity of units S3 - Secondary quantity of units if primary is exceeded; but allocated only when the dataset expands. (S3 X 15 or 16 or 123 secondary allocations - called Extents) S4 - Number of Directory blocks (applicable for PDS only)

S5 - Releases the unused space requested


You get 5 tracks + (2 X 15) tracks = 35 tracks

EXAMPLE: SPACE=(TRK,(5,2))

138

The DD statement Space (CYL / TRK)


Disk surfaces are divided into Tracks of recording space
Group of tracks make a Cylinder Many cylinders make a disk Volume

contd..

139

The DD statement - Space (CYL/TRK)

contd..

Different models of IBM Mainframe disks have different track capacities, number of cylinders and device capacities.
Disk Volume Model Bytes/Track Tracks/Cylinder Total Cylinders Total Bytes

d 3390-1
3390-2

56664 56664

15 15

1113 2226

0.946 Gb 1.892 Gb

140

The DD statement Space (EXTENTS)

contd..

The smallest unit of space on mainframe disks is one whole track. The OS cannot split tracks for use by other datasets
One or more contiguous tracks or cylinders allocated to a dataset are called an EXTENT

An EXTENT is a piece of disk space.

Your primary space allocation is 1 extent.

d When you request SPACE=(TRK,(5,2)) you get:


1 primary extent 5 tracks and + 15 secondary extents (2 X 15) tracks

141

The DD statement Space (Block size)

contd..

You can specify space request by Block size instead of Tracks or Cylinders.
EXAMPLE: SPACE=(3840,200) You get 200 blocks each holding 3840 bytes = 768,000 bytes on the disk If you code a secondary allocation: SPACE=(3840,(200,60)) plus (60 X 3840 bytes X 15 Extents) as secondary allocation

Since one track is the minimum unit of space, if block size requested works out smaller than one track, you still get one track of disk space.

142

The DD statement SPACE (Record Length) contd..


Applicable only for SMS managed datasets
Code AVGREC parameter along with Space parameter Do not code BLKSIZE in the DCB keyword parameter
//DDN // // // DD DSN=DSRC012.DS, DISP=(NEW,CATLG,DELETE), UNIT=SYSDA, AVGREC=U,

//
// d // With AVGREC=U:

SPACE=(133,10000)
RECFM=FB, LRECL=133

You get (10000 records X 133 bytes) of space The 133 in Space parameter is the average Record length in bytes =U means that the 10000 is a unit estimate of the quantity of records to be written.

143

The DD statement SPACE (Record Length) contd..


//DDN
// // //

DD

DSN=DSRC012.DS,
DISP=(NEW,CATLG,DELETE), UNIT=SYSDA, AVGREC=U,

//

SPACE=(133,10)

You get (10 records X 133 bytes) of space. For Secondary allocation request: SPACE=(133,(10,2)) AVGREC can support record quantities by thousands (AVGREC=K) and by millions (AVGREC=M)

d
// // AVGREC=M, SPACE=(133,10)

You get (10,000,000 records X 133 bytes) of space.

144

The DD statement-SPACE (Directory Blocks)

contd..

While creating a PDS, the SPACE parameter is to include a request for Directory Blocks
Space=(TRK,(1,2,7)) You get 1 + (2 X 15) = 31

tracks and create 7 Directory


blocks. Each directory block can store information about 5 members; implies 35 members can be allocated. When you do not want secondary space for the PDS.

d
Space=(TRK,(1,,7))

145

The DD statement - SPACE


EXAMPLES:
//DDN DD DSN=., // // // DISP=.., UNIT=3390, Space=(TRK,10)

contd..

Allocates a PS with 10 tracks of space.

Space=(TRK,(5,,1))

Allocates a PDS with no secondary


space and 1 directory block.

Space=(3840,(200,60))

Allocates (200 X 3840) + (60 X

3840 X 15) of disk space.

146

The DD statement - SPACE

contd..

You receive the secondary space requested for your dataset only as the dataset expands; as you use it
You can get up to 16 extents of secondary space per dataset per disk volume for a PS If you use more than one disk volume for a PS dataset, it can spread up to 16 secondary extents on each volume

A PDS cannot span disk volumes

d
The limit of 16 extents per dataset per disk volume does not apply to VSAM datasets, which can exist with up to 123 extents

147

The DD statement SPACE (RLSE)

contd..

Causes all of the whole unused tracks to be freed for use by other datasets Syntax:
SPACE=(6200,300,RLSE) SPACE=(6200,(300,60),RLSE) SPACE=(80,1,RLSE) d Releases unused tracks. Releases unused tracks in the last active secondary. No space is released since space is less than a track for any disk volume model.

148

The DD statement SPACE (RLSE)


RLSE does not work if a step abends

contd..

Does not work if the dataset is not closed normally Does not work when the dataset is shared

149

The DD statement - DCB


Syntax for Data Control block
Specifies to the OS, the characteristics of the dataset used:

Whether the records are of fixed length or variable length or Undefined length

F V U LRECL n * LRECL

The logical record length Size of record-blocks

150

The DD statement DCB (DCB merge)

contd..

The OS uses this information to work on the datasets.


The OS puts the information specified in this DCB parameter of the DD statement, into its own memory area called Data Control Block. The OS actually uses this Data Control Block to work on the datasets. The OS gets information into its data control block from three sources and follows this sequence, called the DCB merge, in seeking information into its data control block: The program being executed Your DCB parameter in the DD statement The label of the dataset (information in the VTOC) If your program provides the OS all the information, then the information specified in your JCL and in the dataset label is ignored by the OS. Provide the information vide DCB in JCL instead of program since, changing in JCL is easier say, the BLKSIZE.

151

The DD statement DCB (RECFM)

contd..

Syntax : DCB=(RECFM=F/FB/FBA/V/VB/VBA/U, LRECL=n, BLKSIZE=multiples of n)


FB VB U A

Fixed length records and records are blocked Variable length and records are blocked Undefined length Used to control printers.

EXAMPLE:
DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
Blocks 100 records; each record 80 bytes in length.

152

The DD statement DCB (LRECL)

contd..

LRECL The length of the logical record


For fixed length records, the dataset contains records all of the same length and hence LRECL = the actual length of the data-bytes. LRECL for fixed length records can range from 1 to 32,760 bytes. You can access all 32,760 bytes. For variable length records, the length of the records vary from an average to a maximum. So, the LRECL = longest data-bytes length + 4 bytes; the 4 bytes called the RDW(record descriptor word) is pre-pended to each record and indicates the actual length of the record in its first two bytes LRECL can be as high as 32,760 but only 32,752 are accessible. For Undefined format, code LRECL=0. Conventionally used to store load modules.

153

The DD statement DCB (BLKSIZE)

contd..

BLKSIZE The size of a block of records; otherwise called the Physical record.

Blocking of records improves processing speed

154

The DD statement DCB (BLKSIZE)

contd..

For fixed length blocked records (RECFM=FB)


Block size is multiples of LRECL. Must not be larger than 32,760 bytes.

Example: DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)

For variable length blocked records (RECFM=VB)


Block size is multiples of LRECL plus 4 bytes, for Block descriptor

word (BDW) which is pre-pended to the block of records. The first two bytes of the BDW indicates the length of the block.
Example: DCB=(RECFM=VB,LRECL=84,BLKSIZE=8404)

155

The DD statement DCB (BLKSIZE)

contd..

For Undefined format (RECFM=U) records, let the OS determine the block size.
DCB=(RECFM=U,LRECL=0)

156

The DD statement

contd

For SMS managed datasets, the Space and DCB can be set to an installation-defined DATACLASS based on the attributes required for the dataset.

157

Chapter 6 - More on the DD STATEMENT

158

Other DD Statements for :


CONCATENATING DATASETS
REFERBACKS SPECIAL DD STATEMENTS
d

159

CONCATENATING DATASETS
Is used when you want to process two or more datasets in sequence as if they were a single dataset.
Say, three sequential datasets are monthly reports Jan.DS, Feb.DS, Mar.DS. To get a quarterly report you can concatenate them.
//IN // // DD DD DD DSN=Jan.DS,DISP=SHR DSN=Feb.DS,DISP=SHR DSN=Mar.DS,DISP=SHR

Say, you want the OS to search several load module d libraries for a member:
//STEP010 //STEPLIB // // EXEC DD DD DD PGM=LM of a program DSN=DSRC012.LOADLIB1,DISP=SHR DSN= DSRC012.LOADLIB2,DISP=SHR DSN= DSRC012.LOADLIB3,DISP=SHR

160

Rules for Concatenation


The sequence in which the datasets are coded is the sequence in which they are concatenated
We can concatenate PDS, PDS members and PS datasets, but not VSAM datasets. Cannot concatenate PDS wholly with sequential datasets. All datasets must have the same RECFM. The LRECL must also be the same for fixed-length records.

LRECL need not be same for variable-length records as long as you place the dataset with the longest LRECL on the first DD d statement.
BLKSIZE need not be same

You can concatenate as many as 114 PDS as PDSs. No concatenation limit on the PDS members or on PS.
Datasets can reside on different devices.

161

HOW TO CONCATENATE?
Concatenate datasets by coding a DD statement for each dataset
//IN // // DD DD DD DSN=Jan.DS,DISP=SHR DSN=Feb.DS,DISP=SHR DSN=Mar.DS,DISP=SHR

DDname should be coded for the first DD statement only d If DUMMY dataset is coded, the rest of the datasets down are not processed
//DD1 // // DD DD DD DSN=A1.PDS,DISP=SHR DUMMY DSN=C1.PDS,DISP=SHR

162

REFERBACKS - *
Backward reference (referback) is used to copy information from a previous DD statement (within the same job) thus simplifying JCL code.
Referback can also be applied to PGM parameter on the EXEC statement On the DD statement, this can be applied to three parameters:

DSN VOL DCB

Syntax:
Parameter=*.StepName.DDname

PGM=*.LKED.SYSLMOD
DSN=*.Step010.DD1 Note : If the DDname points to a DD statement in the same job step, you can omit the StepName.

163

EXAMPLE
Referback on a DD statement
//DSRC012A //STEP010 //DD1 JOB EXEC DD NOTIFY=DSRC012 PGM=PGM1 DSN=EMP.PDS,DISP=(NEW,CATLG),

//
// //DD2 //STEP2 //DD2 DD EXEC DD

DCB=(LRECL=80,RECFM=FB,BLKSIZE=800),
DSN=INP.PDS,DCB=*.DD1, .. PGM=PGM2 DSN=STU.PDS,DCB=*.STEP010.DD1, ..

Referback on a PGM parameter


JOB EXEC DD EXEC NOTIFY=DSRC012 PGM=HEWL DSN=PDS(M1),DISP=SHR PGM=*.STEP010.SYSLMOD

//DSRC012A //STEP010 //SYSLMOD //STEP020

//..

164

SPECIAL DD STATEMENTS
JOBLIB STEPLIB SYSPRINT SYSIN SYSABEND SYSMDUMP SYSUDUMP

165

JOBLIB
Used to identify a program library (PDS) to search first when attempting to locate load modules (PGM=) executed within the entire JOB Must be placed after the JOB statement and before the first EXEC statement in the JOB More than one program library can be concatenated

d
If a STEPLIB is specified in a JOB that also has a JOBLIB, the STEPLIB takes precedence when searching for a program

166

EXAMPLE
If two load modules are members of the same PDS then execute the load modules by
//DSRC012A
//JOBLIB //STEP1 //. //STEP2 //.

JOB
DD EXEC EXEC

NOTIFY=DSRC012
DSN=<PDS name>,DISP=SHR PGM=<LM member name> PGM=<LM member name>

The OS searches the JOBLIB DSN for the two load modules.

167

STEPLIB
The STEPLIB DD statement is used to identify a program library to search first when attempting to locate load modules (PGM=) executed during the JOB STEP
More than one program library can be concatenated If a STEPLIB DD is specified in a JOB that also has a JOBLIB, the STEPLIB takes precedence when searching for a program

d
JOBLIB / STEPLIB is used to specify private program libraries

168

EXAMPLE
If two load modules are stored as members of two different PDSs, then execute the load modules by
//DSRC012A //STEP1 //STEPLIB //. JOB EXEC DD NOTIFY=DSRC012 PGM=<LM member name> DSN=PDS1, .. (where the above LM is stored) //STEP2 //STEPLIB EXEC DD PGM=<LM member name > DSN=PDS2, . (where the above LM is stored)

//.
The OS searches the respective STEPLIB DSNs for the two load modules.

169

SYSPRINT
Specifies that an execution report of the load module (PGM) is required. It defines the output file containing the execution messages.
EXAMPLE:

//STEP1
//SYSPRINT // Note:

EXEC
DD

PGM=IEBGENER
SYSOUT=*

//SYSUT1

The SYSOUT parameter specifies the output stream dataset. It routes the report to the class (device) mentioned. SYSOUT=CLASS-code, is the syntax. The class can be any alphanumeric character or an asterisk(*), which refers to the device coded in the MSGCLASS parameter of JOB statement.

170

SYSIN
Used to begin an Input stream dataset; supplies data to the load module
Instream datasets begin with the parameters * or DATA in the SYSIN DD statement Format: //SYSIN
EXAMPLE:

DD
EXEC DD DD

* or DATA, or DSN
PGM=LOAD1 DSN=EMP.PDS,DISP=MOD *

d//STEP2
//STEPLIB //SYSIN /*

HELLO WORLD

171

SYSABEND,SYSUDUMP,SYSMDUMP
These are Abnormal termination dumps used to find the source of an error when a program abnormally terminates Coded after the EXEC statement

172

SYSUDUMP
Used to request a formatted dump of the program area, including the contents of the register, a traceback of subroutines called and information about all the datasets used
The dump can be allocated to the SYSOUT CLASS, DASD or TAPE.

SYNTAX:

d//STEP010

EXEC

PGM=LM of an Application program SYSOUT=Class

//SYSUDUMP DD

173

SYSABEND
Used to request a dump similar to that of SYSUDUMP and additionally the system nucleus.

174

SYSMDUMP
Similar to the request of SYSABEND but the dump is
unformatted.

175

Chapter 7 - UTILITY PROGRAMS

176

What is a Utility program?


A program used by all users for the same purpose.

Say, a compiler program (IGYCRCTL) used for compiling Cobol source codes.
A linkage-editor program (HEWL) used for link-editing the above compiled object codes.

Utility programs provide many useful functions

Creating datasets Copying datasets

Sequencing datasets
Deleting datasets and so on

177

IBM Utility programs

contd

IBM supplied utility programs that you run in batch are:


The IBM Utilities Used only on normal datasets VSAM IDCAMS utility Used on normal and VSAM datasets

Both the utilities functions can be and are easier done using TSO or ISPF d

178

Utility programs - IDCAMS

contd

The JCL statements for invoking the utility programs take the form:

The IDCAMS Utility


//Stepname EXEC DD PGM=IDCAMS SYSOUT=*

//SYSPRINT

This prints the IDCAMS messages

//DDname

DD

DSN=.

You can code more than one DD statement depending on the operation; say to copy from one DSN to another. //SYSIN /* DD * REPRO INFILE(DDname1) OUTFILE(DDname2) Command statements

179

Utility programs - IDCAMS

contd

The Commands perform the operations which include:


COMMAND DEFINE REPRO DELETE PRINT OPERATION To allocate a dataset To copy from one dataset to another To delete a dataset To print a dataset

RENAME

To rename a dataset
To list the system catalog information on datasets

d LISTCAT

180

Utility programs IBM Utilities

contd

The JCL statements in IBM Utilities take the form:


//Stepname //SYSPRINT EXEC DD DD PGM=the utility program-name SYSOUT=* ..

This prints the utility programs messages //SYSUT1 Based on the operation, specifies the input dataset

//SYSUT2
//SYSIN

DD
DD

..
*

d Specifies the output dataset based on the operation


Control Statements

/*

COPY INDD=SYSUT1, OUTDD=SYSUT2

181

Utility programs IBM Utilities

contd

The Control statements vary based on the utility program and the operation (to allocate or copy or delete datasets)
IEBGENER Copies sequential datasets. Use IDCAMS REPRO statement instead. Note that members of PDS are sequential datasets too. Copies PDSs (use IDCAMS REPRO) and Compresses a PDS Compares datasets. Instead use the SUPERC utility of ISPF which can be run on-line or in batch. Lists DASD information. USE IDCAMS LISTCAT statement instead.

IEBCOPY

IEBCOMPR
IEHLIST

182

Utility programs IBM Utilities


IEHPROGM

contd

IEBUPDTE IEFBR14

Renames, deletes, catalog and uncatalog datasets, creates special datasets called Generation data groups (GDG). Use IDCAMS ALTER, DEFINE, DELETE statements instead. Maintains PROCS and Source libraries. Allocates datasets. USE IDCAMS DEFINE statement instead.

183

IEFBR14 program
Commonly called a NULL program
Uses:

To allocate (empty) datasets PS, PDS As a house-keeping measure to check the existence of a dataset (using DISP parameter )

184

IEFBR14 - To create a new dataset (PS)

contd..

To create a new and empty PS which is to store fixed length records each of 80 bytes.
//DSRC012A //STEP010 //SYSPRINT //DDNEW // // // d // // JOB EXEC DD DD NOTIFY=DSRC012 PGM=IEFBR14 SYSOUT=* DSN=DSRC012.NEW.DS, DISP=(NEW,CATLG,DELETE), SPACE=(TRK,(1,1)), DCB=(LRECL=80, RECFM=FB, BLKSIZE=8000)

Conventionally, new datasets are allocated using ISPF or TSO instead of the above program.

185

IEFBR14 To create a new PDS

contd..

To create an empty, New, Fixed PDS Dataset.


In the Space parameter, code the directory blocks as:
// SPACE=(TRK,(1,1, number of directory blocks))

186

IEFBR14 - Create PS with variable length records

contd..

To create a new dataset with variable length records, the longest record being 80 data-bytes.

In the DCB parameter, code:


// DCB=(LRECL=84,RECFM=VB,BLKSIZE=8404)

187

IEFBR14 - For house-keeping on datasets


//DSRC012A JOB NOTIFY=DSRC012

//STEP010 //SYSPRINT //DDNEW d // // //


// //

EXEC DD DD

PGM=IEFBR14 SYSOUT=* DSN=DSRC012.NEW.DS, DISP=(NEW,CATLG,DELETE), SPACE=(TRK,(1,1)), DCB=(LRECL=80,


RECFM=FB, BLKSIZE=8000)

188

IEBGENER
Uses:

To copy sequential datasets To reformat records while copying


Can be compared to selecting specific columns

To specify conditions while copying


Can be compared to selecting specific rows

To re-block copied records


Changing the LRECL and BLKSIZE

To concatenate datasets

d To write instream data into a dataset

189

IEBGENER To copy
To copy sequential datasets

contd..

For backing-up purposes For expanding space allocation EXEC DD DD DD DD PGM=IEBGENER SYSOUT=* DSN=<Input dataset to be Read from> DSN=<Output dataset to be Written into> DUMMY

//STEP010 //SYSPRINT //SYSUT1 //SYSUT2 //SYSIN

d//
The input dataset can be a PS or a member of PDS The output dataset can also be a PS or a PDS member

The input and output datasets can both be PS or PDS members


Output datasets as PS apply to backing-up operations on tapes

190

IEBGENER To copy

contd..

To copy an input sequential dataset to many members of a PDS


Code Generate Maxname and Member name.
//DSRC012A
//STEP010 //SYSPRINT //SYSUT1

JOB
EXEC DD DD

NOTIFY=DSRC012
PGM=IEBGENER SYSOUT=* DSN=<Input dataset>

//SYSUT2

DD
DD

DSN=<Output PDS>
*

//SYSIN

Generate Maxname=3 (To create 3 members in the output)

Member name=(mem1,mem2,mem3)
(mem1,mem2,mem3 will have the contents of sysut1) /*

191

IEBGENER

To Reformat data during copy

contd..

By reformatting, you can select data-bytes to be output


Code Generate Maxflds and Record Field in the control

statement (similar to Inrec Fields in Sort utility)

Say, to output only the Empnum and Salary data-bytes, in the order of Salary and Empnum:
//STEP010 //SYSPRINT EXEC DD DD DD DD PGM=IEBGENER SYSOUT=* DSN=<Input dataset> DSN=<Output dataset> *

//SYSUT1 //SYSUT2 //SYSIN

Generate Maxflds=2
Record field=(5,1,CH,6) field=(5,46,CH,1) (Length,Location in input,Format,Location in the output)

192

IEBGENER -

To Reformat data during copy

contd..

And to have some character-literals in the output, say, two

asteriks between Salary and Empnum fields (similar to X in the Sort utility), code Maxlits:
//STEP010
//SYSPRINT //SYSUT1 //SYSUT2 //SYSIN

EXEC
DD DD DD DD

PGM=IEBGENER
SYSOUT=* DSN=<Input dataset> DSN=<Output dataset> *

Generate Maxflds=2,Maxlits=2 Record field=(5,1,CH,8) field=(5,46,CH,1) (Length,Location in input,Format,Location in the output) field=(2,**,,6)

193

IEBGENER -

To Reformat data during copy

contd..

If output is to be routed to the three PDS members, but to perform reformatting only in the second member

//SYSIN

DD

Generate Maxname=3,Maxflds=2 Member name=mem2 Record field=(5,1,ch,8) field=(5,46,ch,1) field=(2,**,,6) Member name=(mem1,mem3)

194

IEBGENER To specify conditions

contd

To select rows of records based on some criteria, say, employees getting a salary of 1000, code Maxgps and Record Ident (similar to Include / Omit Cond of Sort utility)
//STEP010
//SYSPRINT //SYSUT1 //SYSUT2

EXEC
DD DD DD

PGM=IEBGENER
SYSOUT=* DSN=<Input dataset> DSN=<Output PDS>

//SYSIN

DD

Generate Maxgps=1 Record Ident=(5,01000,46) (length,<condition>,start-byte)

195

IEBGENER - To re-block records


Re-blocking can involve:

contd..

Altering the BLKSIZE sub-parameter of the DCB in the output Altering the LRECL too
Code GENERATE control statement

Say to alter the LRECL in output:


//STEP010 EXEC DD DD DD PGM=IEBGENER SYSOUT=* DSN=<Input dataset> DSN=<Output dataset>, . DCB=(LRECL=100,..,BLKSIZE=10000)

d//SYSUT1

//SYSPRINT //SYSUT2

//SYSIN

DD

Generate Maxflds=1 Record field=(80,1,CH,1)


/*

196

IEBGENER To concatenate datasets


DD statements) //DSRC012A JOB NOTIFY=DSRC012

contd..

To concatenate two datasets (note the PGM and the SYSUT1

//STEP010
//SYSPRINT //SYSUT1 //

EXEC
DD DD DD DD DD

PGM=IEBGENER
SYSOUT=* DSN=<First unsorted dataset> DSN=<Second unsorted dataset> Concatenation DSN=<The concatenated dataset> DUMMY

d//SYSUT2
//SYSIN //

197

IEBGENER - To write instream data


To write instream data into a dataset
//DSRC012A //STEP010 //SYSPRINT //SYSUT1 JOB EXEC DD DD NOTIFY=DSRC012 PGM=IEBGENER SYSOUT=* *

contd..

<Instream data>

/*

d//SYSUT2
//SYSIN //

DD DD

DSN=<Output dataset to be Written into> DUMMY

198

IEBCOPY To copy as a PDS


To copy a PDS as a PDS
Often used to expand the space allocation or change the directory space. Say, to increase the directory blocks:
//STEP010 //SYSPRINT //SYSUT1 //SYSUT2 EXEC DD DD DD PGM=IEBCOPY SYSOUT=* DSN=Existing PDS name,DISP=(Shr,Delete) (say, this PDS has 10 directory blocks) DSN=New PDS name,

//

SPACE=(TRK,(10,5,50),RLSE),. (you request 50 directory blocks) DD *

// //SYSIN /*

COPY INDD=SYSUT1,OUTDD=SYSUT2

You can merge many input PDSs too. DDnames are necessary for merge.

199

IEBCOPY

contd..

You can further rename the new PDS to that of the deleted PDS. Use IDCAMS ALTER command.
//STEP010 //SYSPRINT //SYSIN EXEC DD DD PGM=IDCAMS SYSOUT=* * name)

ALTER <New PDS name> NEWNAME(Original dataset /*

200

IEBCOPY

contd..

You can alter the BLKSIZE but not the LRECL using IEBCOPY

201

IEBCOPY

contd..

Determining the IEBCOPY operation to be performed:


To request a COPY operation, specify partitioned data sets as input and output
Used to expand the space allocation, change the directory space or change the blocking size.

To request an UNLOAD operation, specify a partitioned input data set and a sequential output data set
Use to create a back-up copy on tape.

To request a LOAD operation, specify a sequential input data set and a partitioned output data set
Used to restore a PDS from tape to DASD.

202

IEBCOPY To copy to a new PDS

contd

To copy selective members from a PDS to a new PDS


Use SELECT MEMBER or EXCLUDE MEMBER in the control statement along with COPY operation. Select and Exclude are mutually exclusive.
//STEP010 //SYSPRINT //SYSUT1 //SYSUT2 EXEC DD DD DD DD PGM=IEBCOPY SYSOUT=* DSN=Existing PDS name,DISP=SHR DSN=New PDS name,DISP=(New,Catlg), *

// //SYSIN

COPY INDD=SYSUT1,OUTDD=SYSUT2

SELECT MEMBER=(member1,member2..)
/*

203

IEBCOPY
You can assign a new name to the copied member

contd

SELECT MEMBER=(member1,(member2,newname), ..)

For a COPY operation on an PDS with members existing, you can

replace identically named members in the output dataset


SELECT MEMBER=(member1,,R)

204

IEBCOPY To compress a PDS

contd..

To restore unused space for use.


//STEP010 //SYSPRINT EXEC DD PGM=IEBCOPY SYSOUT=*

//INOUT
//SYSIN /*

DD
DD

DSN=Existing PDS name,DISP=Old


*

COPY INDD=INOUT,OUTDD=INOUT

Since input and output datasets are the same, must code COPY control statement.

205

IEBCOMPR
Uses

To locate data-differences between two datasets. Comparison occurs at the record-level. Normally used to ensure accuracy of back-ups taken.
Can compare two sequential or partitioned datasets.

To compare two PDSs:


////

//STEP010 EXEC PGM=IEBCOMPR //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=<Dataset1>,DISP=Old //SYSUT2 DD DSN=<Dataset2>,DISP=Old //SYSIN DD * COMPARE TYPORG=PO /* RC of 0 implies no data-differences. RC of 8 implies differences.

206

SORT Program - DFSort


Can be invoked vide SORT verb in COBOL Vide JCL you invoke as a job step

To sequence character data and numeric data in ascending or descending order


Character data sequenced from left to right; comprises aphabetic, alphanumeric and numeric characters. In d ascending order:

+9 and then -9

(+ comes before -)

Numeric data sequenced based on the numeric value, taking sign too into consideration. In ascending order:
-9 and then +9 (-9 is less than +9)

207

SORT Program DFSort


To reformat data to be sorted

contd

Can be compared to selecting specific columns

To specify conditions for selecting data

Can be compared to selecting specific rows

To concatenate datasets and sort

208

SORT Program - To sequence a dataset

contd.

Character data and Numeric data are sorted differently. The following fields are listed in ascending sequence for both character and numeric data.
As character data +9, -9 b9, -9 (+ comes before -) (Blank comes before -)

b999, 0009

(Blank comes before zero)

d
As Numeric data -9, +9 -9, 9 9, 999 (-9 is less than +9) (-9 is less than 9) (9 is less than 999)

209

SORT Program - To sequence a dataset

contd.

Sort order of alphanumeric data (character data) is called its Collating sequence, which specifies the sort order of each character in the character set

Two main collating sequences are EBCDIC and ASCII; the mainframe OS uses EBCDIC
EBCDIC blank .<(+I=&!.= a through z ASCII blank !#.()+,-./ 0 through 9 :;< = >?@ A through Z [\] a through z {I}-

A through Z 0 through 9

210

SORT Program - To sequence a dataset


To Sequence A Dataset

contd.

Consider the following layout of a PS with fixed length records:

Empno
Empname

:starting at absolute byte 1, for 5 bytes long


:at absolute byte 6, for 25 bytes long

Department :at absolute byte 31, for 15 bytes long d

Salary

:at byte 46, for 5 bytes long

211

SORT -To sequence a dataset

contd..

The PS being populated with the following records:


11111sujit 55555danny 22222ajay 33333mala admin marketing admin projects 10000 15000 07000 20000

212

SORT -To sequence a dataset

//DSRC012A JOB NOTIFY=DSRC012

contd..

To sort in ascending order of Empno, the JCL is:


EXEC DD PGM=SORT SYSOUT=*

//STEP010 //SYSPRINT

//SYSOUT
//SORTIN //SORTOUT

DD
DD DD DD

SYSOUT=*
DSN=<the unsorted dataset> DSN=<The destination dataset name for sorted data> *

d//SYSIN

SORT FIELDS=(1,5,CH,A) The control statement supplies a Sort-Key implying: /* Start sorting the record at the absolute byte address (1), Length, the number of bytes to be included in sorting (5) , Format of sorting (EBCDIC character),

Sequence of sorting (ascending)

213

SORT -To sequence a dataset

contd..

The sorted dataset will contain :


admin 10000

11111sujit

22222ajay
33333mala 55555danny

admin
projects marketing

07000
20000 15000

Note: For VB records, the first data-byte is 5.

214

SORT -To sequence a dataset

contd..

The Sort control statement takes the form:

SORT FIELDS=(Sort-key1, Sort-key2, ) (Start,


Starting data-byte position in the

Length,
Length of data to be sorted.

Format,

Order)
Ascending, Descending

record. Databytes 1 to d 4092 only can be the start bytes CH AC FS EBCDIC character ASCII character Signed numeric character

in the sort-key.

D1

User-defined data type.

The keys are listed from left to right in the major to minor order.

215

SORT -To reformat data to be sorted


By reformatting:

contd..

You can select data-bytes (columns) to be output and sort on those columns Since the start data-byte in the sort-key can be only within the first 4092 data bytes, to consider data beyond 4092 bytes as the start data-byte, you can reformat.

To reformat, code:

Before sort fields,INREC FIELDS to reformat the record before sorting


After sort fields, OUTREC FIELDS to reformat the record after sorting

216

SORT -To reformat data to be sorted

contd..

Before sorting, to include only employee number and salary field and to sort in descending order of salary field:
DD * 5555515000

//SYSIN

INREC FIELDS=(1,5,46,5)-----------------------1111110000 SORT FIELDS=(6,5,CH,D)

/*

2222207000
3333320000

d
The sorted dataset will contain:

3333320000
5555515000 1111110000 2222207000

217

SORT -To reformat data to be sorted

contd..

If data beyond 4092 bytes, say, at the 5000th byte is to be considered as the start position in the sort-key and sequencing to be done in ascending order of that field, then :
DD *

//SYSIN

INREC FIELDS=(1,5,5000, say length of 3) SORT FIELDS=(6,3,CH,A) /*

218

SORT -To reformat data to be sorted

contd..

To reformat data-bytes after sorting, OUTREC FIELDS is used. Also used to space out fields in the output.
To obtain only the Empno and Salary fields in the output, but to sort on Empname field in ascending order:

d //SYSIN

DD * SORT FIELDS=(6,25,CH,A) ------------------------- 22222ajay. OUTREC FIELDS=(1,5,46,5) 55555danny.. 33333mala The output dataset will contain: 2222207000 11111sujith 5555515000 3333320000

1111110000

219

SORT -To reformat data to be sorted

contd..

To include character-literals, say, spaces between the Empno and Salary fields in the output dataset:
Code OUTREC FIELDS=(1,5,2X,46,5) Two spaces

The output dataset will contain: 22222 07000 55555 15000 33333 20000

11111 10000

220

SORT To specify conditions

contd..

To select records (rows) based on some criteria, INCLUDE COND or OMIT COND is used Takes the form,
Include / Omit Cond=(Start-byte,Length,Format,Comparison,Constant)

Code before Sort Fields and Inrec Fields


//SYSIN DD *

d Include / Omit Cond=


Inrec Fields= Sort Fields= /* Decimal constant Hexadecimal Character 12,-16,222,46 Xnnnnnn Ccharacter-literals

221

SORT To specify conditions

contd..

To select employees getting a salary of 1000 and sort in ascending order of employee number
//SYSIN DD * INCLUDE COND=(46,5,CH,EQ,C1000) SORT FIELDS=(1,3,CH,A) /*

Conversely, Omit Cond can be used to exclude employees with salary of 1000.

INCLUDE and OMIT are mutually exclusive

Can use connect operators AND and OR to form several logical conditions

222

SORT - To concatenate datasets & sort

contd..

To Merge two unsorted datasets into one sorted dataset


(note the SORTIN DD statements and the control statement)

//DSRC012A //STEP010 //SYSPRINT //SYSOUT //SORTIN

JOB EXEC DD DD DD DD DD

NOTIFY=DSRC012 PGM=SORT SYSOUT=* SYSOUT=* DSN=<First Unsorted Dataset> DSN=<Second Unsorted Dataset> Concatenation DSN=<SORTED DATASET>

d//
//SORTOUT

//SYSIN
/*

DD

SORT FIELDS=(1,5,CH,A)

223

SORT - To concatenate datasets & sort

contd..

To Merge two datasets using MERGE FIELDS instead SORT FIELDS

Requires sorting of the datasets to merge.(Note the two SORTIN DD


statements and the control statement) //DSRC012A //STEP010 //SYSPRINT //SYSOUT //SORTIN01 //SORTIN02 //SORTOUT //SYSIN /* JOB EXEC DD DD DD DD DD DD NOTIFY=DSRC012 PGM=SORT SYSOUT=* SYSOUT=* DSN=<First Sorted dataset> DSN=<Second Sorted dataset> DSN=<SORTED DATASET> *

MERGE FIELDS=(1,5,CH,A)

224

DFSORT Merge Fields


It is erroneous to merge (MERGE FIELDS) two datasets of varying LRECL

But can concatenate two varying length datasets as long as the highest LRECL is coded first.
The concatenated output will take on the highest LRECL

225

Chapter 8 - PROCEDURE

226

PROCEDURE (PROC) What is it ?


JCL used repeatedly by several users to perform the same function.

Say language compiler and linkage editor programs


//Cobol EXEC PGM=IGYCRCTL //SYSIN DD DSN=COBOL source pgm //other DD statements

//SYSLIN DD DSN=OBJECT module EXEC PGM=IEWL d //Lked //SYSLIN DD DSN=OBJECT Module //other DD statements. //SYSLMOD DD DSN=LOAD Module

227

PROCEDURE (PROC) What is it ?

contd

Consider Utility programs


EXEC DD DD DD DD PGM=SORT SYSOUT=* SYSOUT=* DSN=<Unsorted Dataset Name> DSN=<Sorted Dataset Name>

//STEP010 //SYSPRINT //SYSOUT //SORTIN //SORTOUT

//SYSIN
/*

DD

d SORT FIELDS=(1,5,CH,A)

228

Why do we need PROCS ?


No repetitiveness of same code by all users
Eliminates coding errors

229

Converting a JCL to PROC


8 steps to convert a JCL to a Procedure

First code an Instream Procedure Then convert the Instream Procedure to a Cataloged Procedure

230

Step1 Test the Raw JCL code


//DSRC012A JOB NOTIFY=DSRC012

//STEP010
//SYSPRINT //SYSOUT //SORTIN //SORTOUT //SYSIN

EXEC
DD DD DD DD DD

PGM=SORT
SYSOUT=* SYSOUT=* DSN=<Unsorted Dataset Name> DSN=<Sorted Dataset Name> *

SORT FIELDS=(1,5,CH,A)

d/*
//

231

Step 2 Code PROC / PEND statements


Separate the JOB statement from the remaining JCL statements, with a PROC operation giving the PROC a name.
//DSRC012A //SORTPROC //PSTEP010 //SYSPRINT //SYSOUT //SORTIN //SORTOUT //SYSIN /* // // PEND JOB PROC EXEC DD DD DD DD DD PGM=SORT SYSOUT=* SYSOUT=* DSN=<Unsorted Dataset Name> DSN=<Sorted Dataset Name> * NOTIFY=DSRC012

SORT FIELDS=(1,5,CH,A)

Separate the null statement(//) from the JCL with a PEND statement.

232

Step 3 Remove control statements


Remove any control statement and put it into a member of a PDS.
//DSRC012A JOB NOTIFY=DSRC012 PGM=SORT SYSOUT=* SYSOUT=*

//SORTPROC
//PSTEP010 //SYSPRINT //SYSOUT

PROC
EXEC DD DD

//SORTIN

DD
DD DD PEND

DSN=<Unsorted Dataset Name>


DSN=<Sorted Dataset Name> DSN=<PDS(Mem1)>, DISP=SHR
SORT FIELDS=(1,5,CH,A)

d//SORTOUT
//SYSIN //

//

Change the JCL to refer to that dataset.

233

Step 4 Use Symbolic parameters (&)


Replace the parameter-values that will change from run to run with SYMBOLIC parameters (&), which are place holders for the actual values.
//DSRC012A
//SORTPROC //PSTEP010 //SYSPRINT

JOB
PROC EXEC DD

NOTIFY=DSRC012
PGM=SORT SYSOUT=&To

//SYSOUT

DD
DD DD DD PEND

SYSOUT=&To
DSN=&Unsorted Dataset DSN=&Sorted Dataset DSN=&PDS(Mem1), DISP=SHR

//SORTIN //SORTOUT //SYSIN // //

234

Step 5 Code default values for Symbolics


If applicable, code default values for the symbolic parameters, on the PROC statement.
//DSRC012A JOB NOTIFY=DSRC012

//SORTPROC
//PSTEP010 //SYSPRINT //SYSOUT

PROC
EXEC DD DD

To= *
PGM=SORT SYSOUT=&To SYSOUT=&To

//SORTIN

DD
DD DD PEND

DSN=&Unsorted Dataset
DSN=&Sorted Dataset DSN=&PDS(Member), DISP=SHR

//SORTOUT //SYSIN // //

235

Step 6 Test the PROC instream the job


Code, EXEC the Proc-Name and assign the actual

values to the symbolic placeholders.


//DSRC012A //PSTEP010 //SYSPRINT //SYSOUT //SORTIN //SORTOUT JOB EXEC DD DD DD DD DD PEND EXEC PROC=SORTPROC, NOTIFY=DSRC012

//SORTPROC PROC

To= *
PGM=SORT SYSOUT=&To SYSOUT=&To DSN=&Unsorted Dataset DSN=&Sorted Dataset DSN=&PDS(Member), DISP=SHR

//SYSIN // //STEP010

//
// //

Unsorted dataset=Name,
Sorted dataset=Name, PDS(Member)=Name

This is called an INSTREAM PROCEDURE. You can code 15 instream procs in 1 job.

236

Step 7 Make Instream to Cataloged PROC


Remove the JOB Statement
//DSRC012A //SORTPROC //PSTEP010 //SYSPRINT //SYSOUT //SORTIN //SORTOUT //SYSIN // //STEP010 // // // JOB PROC EXEC DD DD DD DD DD PEND EXEC PROC=SORTPROC, Unsorted dataset=Name, Sorted dataset=Name, PDS(Member)=Name NOTIFY=DSRC012 To= * PGM=SORT SYSOUT=&To SYSOUT=&To DSN=&UNSORTED DATASET DSN=&SORTED DATASET DSN=&PDS(Member), DISP=SHR

Remove the PEND and other statements thereafter


Save code in a private PDS member to evolve a cataloged procedure in user private library, or save in the system library SYS1.PROCLIB.

237

Step 8 Test the Cataloged Proc


Code an invoking JCL

Code JCLLIB ORDER statement for Cataloged procedures stored in user private libraries.
//DSRC012A
// //STEP010 //

JOB
EXEC

NOTIFY=DSRC012
PROC=SORTPROC, Unsorted dataset=Name,

JCLLIB ORDER=<Location of Cataloged Procedure>

//

Sorted dataset=Name,
PDS(Member)=Name

// //

238

Using a Procedure
Users invoke a Proc by coding EXEC Proc-Name or PROC=Proc-Name Based on the userss specific processing needs, a PROC can be used by:

Assigning actual values to the symbolic parameters in the proceure Overriding the existing parameters of the EXEC and DD statements in the procedure Nullifying the existing parameters of the EXEC and DD statements in the procedure Adding new DD statements to the procedure

Adding new parameters to the EXEC and DD statements in the procedure


//SORTPROC //PSTEP010 //SYSPRINT //SYSOUT PROC EXEC DD DD To= * PGM=SORT SYSOUT=&To SYSOUT=&To

//SORTIN
//SORTOUT //SYSIN

DD
DD DD

DSN=&UNSORTED DATASET
DSN=&SORTED DATASET DSN=&PDS(Member), DISP=SHR

239

Assigning values to symbolic parameters


//SORTPROC //PSTEP010 //SYSPRINT //SYSOUT //SORTIN //SORTOUT PROC EXEC DD DD DD DD To= * PGM=SORT SYSOUT=&To SYSOUT=&To DSN=&UNSORTED DATASET DSN=&SORTED DATASET

//SYSIN

DD

DSN=&PDS(Member), DISP=SHR

//DSRC012A

JOB EXEC

NOTIFY=DSRC012 PROC=SORTPROC, Unsorted dataset=Name, Sorted dataset=Name, PDS(Member)=Name

// //STEP010 // // //

JCLLIB ORDER=<Location of Cataloged Procedure>

240

Overriding the parameters of the Exec and DD


//SORTPROC PROC //PSTEP010 //SYSPRINT EXEC DD To= * PGM=SORT,Time=(,1) SYSOUT=&To

//SYSOUT
//SORTIN //SORTOUT //SYSIN //DSRC012A

DD
DD DD DD

SYSOUT=&To
DSN=&UNSORTED DATASET DSN=&SORTED DATASET DSN=&PDS(Member), DISP=SHR JOB EXEC NOTIFY=DSRC012 PROC=SORTPROC, Unsorted dataset=Name, Sorted dataset=Name, Time.PSTEP010=(,5) DD *

d //
// //

JCLLIB ORDER=<Location of Cataloged PROC>

//STEP010

//PSTEP010.SYSIN /*

SORT FIELDS=(1,5,CH,A)

Parameter. Procs Stepname Procs Stepname . DDname

//

241

Nullifying the parameters of the Exec and DD


Code as with Overriding the parameters but do not pass the value

Code just an equal (=) sign after the parameter


//SORTPROC PROC //PSTEP010 //SYSPRINT //SYSOUT //SORTIN //SORTOUT //SYSIN EXEC DD DD DD DD DD To= * PGM=SORT,Time=(,1) SYSOUT=&To SYSOUT=&To DSN=&UNSORTED DATASET DSN=&SORTED DATASET DSN=&PDS(Member), DISP=SHR

//DSRC012A // //STEP010

JOB

NOTIFY=DSRC012

JCLLIB ORDER=<Location of Cataloged PROC> EXEC PROC=SORTPROC,

//
// //PSTEP010.SYSOUT //

Unsorted dataset=Name,
Sorted dataset=Name,Time.PSTEP010= DD SYSOUT=

242

Adding new DD statements to the PROC


//SORTPROC PROC
//PSTEP010 //SYSPRINT //SYSOUT EXEC DD DD

To= *
PGM=SORT SYSOUT=&To SYSOUT=&To

//SORTIN
//SORTOUT //SYSIN

DD
DD DD

DSN=&UNSORTED DATASET
DSN=&SORTED DATASET DSN=&PDS(Member), DISP=SHR

//DSRC012A

JOB
EXEC

NOTIFY=DSRC012
PROC=SORTPROC, Unsorted dataset=Name, Sorted dataset=Name

// //STEP010 // //

JCLLIB ORDER=<Location of Cataloged PROC>

//PSTEP010.SYSIN
/* //

DD

SORT FIELDS=(1,5,CH,A)

Procs Stepname . DDname

243

Adding new parameters to the EXEC and DD


Code as with overriding the parameters and pass the values.
//SORTPROC PROC //PSTEP010 //SYSPRINT EXEC DD To= * PGM=SORT SYSOUT=&To No TIME parameter

//SYSOUT
//SORTIN //SORTOUT //SYSIN

DD
DD DD DD

SYSOUT=&To
DSN=&UNSORTED DATASET DSN=&SORTED DATASET DSN=&PDS(Member) No DISP parameter

//DSRC012A

JOB
EXEC

NOTIFY=DSRC012
PROC=SORTPROC, Unsorted dataset=Name, Sorted dataset=Name,

// //STEP010 // //

JCLLIB ORDER=<Location of Cataloged PROC>

//
// //PSTEP010.SYSIN // DD

PDS(Member)=Name
Time.PSTEP010=(,5) DISP=SHR

244

Notes on Procedures
A Job can contain 15 instream procedures.
An Instream procedure can call a Cataloged procedure. A Cataloged procedure cannot call an Instream procedure. A Cataloged procedure can call a Cataloged procedure.

There can exist a maximum of 15 nested PROC statements PROC operation

If each procedure resides in 15 different PDS, then the JCLLIB ORDER must identify those PDS to the OS.

Restart a PROC - Syntax <Jobs Step name . PROCs Step name>


d Forward reference Syntax - //DDName DD DDName=fwd

Then use fwd in the name field on any subsequent DD statement

In the invoking JCL of PROCs, overriding statements must come before add-on statements

Override DD statements in the order of their occurrence within the PROC.

245

Notes on Procedures
To override a parameter on all the steps in a PROC with the same value, call the PROC and code the parameter=its value.
You can add-on and override DD parameters only one level down from the invoking step

If the called PROC is not found in the private libraries of the JCLLIB order statement, then the OS searches the system library even though not coded in the JCLLIB statement
To override only certain concatenated datasets in a PROC, in the calling JCL, code just DSN for those datasets which need not be overidden d

246

Chapter 9 - GENERATION DATA GROUPS


d

247

Use of Generation Data Groups


A Generation Data Group (GDG) is used for processing data sets that are to be created on a periodical basis monthly or weekly or daily or hourly.
Examples :

Processing Payroll
Invoicing regular customers Income Tax report Backup

Statistics
Audit Trails

In each processing cycle, a new generation (updated version) of the dataset is generated.

248

Referring a GDG
All generations have the same dataset name.

Referred to by the name and a relative generation number


the current tax report last years tax report new generation

DSN=DSRC012.Tax.State(0) DSN=DSRC012.Tax.State(-1) You add a new generation by calling it: DSN=DSRC012.Tax.State(+1)

d Upto 255 relative generations can exist and must be cataloged. Generations of a GDG are sequential and can reside on disk or tape.

249

Advantages of GDG
No need to change the JCL between runs

The same DD statements can be used to create each new generation


//STEPCRTE EXEC PGM=IEFBR14

//DD1
// // //

DD

DSN=DSRC012.Tax.State(+1),
DISP=(NEW,CATLG), SPACE=(TRK,(1,5), DCB=DSRCO12.MODL.MODL

d The system keeps track of adding and deleting successive


generations

250

Catalog entry for a GDG


In the system catalog, each generation has a name with its absolute generation number
GDGname.GaaaaVnn, where aaaa absolute generation number, 0001 to 9999 nn version number, 00 to 99

251

3 steps to Create a GDG


Create an entry for the GDG in the system catalog

This entry is called the GDG Base - DSRC012.BASE.GDG

For non-SMS managed datasets, the second step involves creating a model dataset for supplying the DCB parameters to the new individual dataset belonging to a group. This model dataset must be cataloged. For SMS managed datasets, this step can be bypassed.

Create the new dataset belonging to a group -

d DSN=DSRC012.BASE.GDG(+1)

252

CREATING THE GDG BASE


Use the IDCAMS utility - DEFINE command
//DSRC012A //STEP010 //SYSPRINT //SYSIN LIMIT(3)EMPTYJOB EXEC DD DD NOTIFY=DSRC012 PGM=IDCAMS SYSOUT=* * NAME LIMIT EMPTY / NOEMPTY Scratch / NoScratch OWNER TO / FOR

DEFINE GDG(NAME(DSRC012.BASE.GDG)-

d SCRATCH)
/* //

253

CREATING THE GDG BASE

contd

NAME : A GDG name can contain maximum of 35 characters


(Since the GnnnnV00 take up 9 positions we have to keep the name to 35 or less characters)

LIMIT : Specifies how many GDS's (generations) are to be


maintained in a group. (Maximum 255) NAME and LIMIT are the mandatory parameters while defining the GDG base

d
EMPTY / NOEMPTY : Specifies what action OS should take when
the LIMIT value is reached. EMPTY means that all generations should be removed (uncataloged) from the group; NOEMPTY means that just the oldest generation should be removed (uncataloged).

NOEMPTY is the default

254

CREATING THE GDG BASE

contd

SCRATCH / NOSCRATCH : Specifies whether or not OS should


scratch (physical deletion) GDS's as they are removed from the group.

NOSCRATCH is the default

OWNER : Specifies 1 to 6 character owner-id for the GDG. TO & FOR : Specifies the expiration date TO(yyyyddd) or a retention

period FOR(dddd) for the GDG

255

CREATING THE MODEL


Use the IEFBR14 utility
//STEP020 //DD1 // // // EXEC DD PGM=IEFBR14 DSN=DSRC012.MODL, DISP=(NEW,CATLG), SPACE=(TRK,0), DCB=(LRECL=80,RECFM=FB)

256

CREATING THE MODEL

contd

The system can use the DCB values given in the model as default values when a new GDS is created
The DCB values can also be overidden while creating the new

GDS.

257

Creating the new generation dataset


Use IEFBR14 utility or a user-written application program
//DSRC012A //STEP010 //DD1 // // JOB EXEC DD NOTIFY=DSRC012 PGM=IEFBR14 DSN=DSRC012.BASE.GDG(+1), DISP=(NEW,CATLG), SPACE=(TRK,(1,5),

//

DCB=DSRCO12.MODL

258

Creating the new generation dataset

contd..

DSN should be coded for new generations, along with the generation number in parentheses.
Disposition should be CATLG for all new generations Generations are referred by the same generation number throughout the various steps in the job

The system updates the generation number only when the job terminates.

259

Creating the new generation dataset

contd..

After the job terminates a new generation is added to the GDG and becomes the current generation
The former current generation becomes a previous generation Relative generation number is used to uniquely identify every data set in the GDG

The current generation is identified as DSN=GDGname(0). The earlier generation is identified as DSN=GDGname(-1) and the second oldest generation is identified as DSN=GDGname(-2) and so on.

d +ve numbers refer to generations not yet created:


DSN=GDGname(+1) DSN=GDGname(+2),.....).

260

Absolute and Relative generation numbers


Consider 3 generations in the catalog:
ABSOLUTE GENERATION NUMBER RELATIVE NUMBER

DSRC062.BASE.GDG

DSRC062.BASE.GDG.G0001V00
DSRC062.BASE.GDG.G0002V00 DSRC062.BASE.GDG.G0003V00

(-2)
(-1) (0)

CURRENT GENERATION PREVIOUS GENERATION OLDEST GENERATION

261

Retrieving a generation dataset


To retrieve an individual dataset, code the dataset name along with the relative generation number If the dataset is coded without the generation number, then all the generations in that group will be concatenated and retrieved

262

Deleting a generation dataset


The system will automatically delete the individual GDS as per the GDG base definition We can also delete a specific generation by coding DISP=(Old,Delete)

To delete the GDG Base we have to use IDCAMS command

263

GDG Notes
If:
//Step010 EXEC PGM=IEFBR14 //DDGDSA DD DSN=GDG.Index(+1),DISP=(New,Catlg). //

//DDGDSB DD DSN=GDG.Index(+2),DISP=(NEW,Catlg).
// After the job terminates normally, (+2) becomes the current relative generation 0, and (+1) becomes the relative generation (-1). But see this: //Step010 EXEC PGM=IEFBR14 //DDGDSA DD DSN=GDG.Index(+2),DISP=(New,Catlg). // This creates an absolute generation rolling forward by +2 ; but the relative generation rolls back by 1 only (ie) +2 becomes 0, the current relative generation.

264

Q&A
If TIME=1, CLASS=A is coded on a JOB statement where class A is
defined for jobs not exceeding 30 secs, will the job run successfully if it requires 45 secs to process? The datasets given in Joblib / Steplib statements cannot be referred back. State - True/False What are the valid DSORG values ? What is the purpose of DD * statement?

a) Begins an input data prompt at the system console b) Begins an in-stream dataset c) Marks the end of a command stream d) Includes all datasets within a naming pattern If your program abends and you need to print the dump generated by the system we can use ----265

Q&A
What will happen if region=0k is coded on job statement?
--------- selectively executes job steps. //AS1 DD DSN=AAA.BBB,UNIT=AFF=AS0; What device does this dataset use? a) Device AS0 b) Device in address AS0 c) Device mentioned in AS0 statement d) Error in coding device

d
What will be the system response for the jcl? //JW1 JOB NOTIFY=DSRC050 What u mean by include statement in JCL? What are the jcl statements that should not be used in INCLUDE groups?

266

Q&A
//ddname DD DATA and //ddname DD * are equivalent
a) Always 0% b) When using default delimiters only 100%

To Create a GDG Dataset we can use both IDCAMS & IEHPROGM


The STEPLIB statement cannot be used in a cataloged procedure - False Recall points on control cards used in SORT

SORTWKnn SORT FIELDS=COPY


If you code both SORT KEY and COPY it is a definer error

MERGE FIELDS SUM FIELDS=NONE,XSUM (SORTOFnn)

All abend codes

267

You might also like