Saturday, 10 August 2013

JCL Data Set Protection: RETPD, EXPDT, DISP, and RACF Basics

JCL data set protection checks for RETPD, EXPDT, DISP, and RACF profile access
Check protection before the job runs.

Last updated: August 31, 2026

A batch job can delete, keep, catalog, or overwrite a data set based on one DD statement. That is why JCL data set protection is not only a security topic. It is also a job-control topic. A small mistake in DISP, RETPD, or EXPDT can keep a file longer than expected, remove it too early, or let the wrong job try to update it.

This guide explains the basic checks in plain English. You will see what JCL controls, what RACF controls, and what to review before a production job touches business data.

What Data Set Protection Means In JCL

In JCL, a data set is a named file used by a batch job. It might be a customer extract, a payroll file, a report, a temporary work file, or a GDG generation. Protection means three practical things:

  • Only approved users and jobs should read or change the data set.
  • The job should use the right disposition, such as keep, catalog, delete, or pass.
  • The data set should not expire or be deleted before the business is finished with it.

JCL helps describe how the job should handle the data set. RACF or another security product decides whether the user or job has access. Storage rules decide how long the data set remains on disk or tape.

The Three JCL Fields To Check First

Field Simple meaning Common check
DSN The data set name. Confirm the job points to the right file, high-level qualifier, and GDG generation.
DISP What the job wants to do with the file. Check whether the job needs old, new, shared, or temporary access.
RETPD or EXPDT How long the file should be retained. Confirm the retention period or expiry date matches the business rule.

DISP: How The Job Handles The Data Set

DISP tells z/OS the starting status of a data set and what to do with it when the step ends. It is one of the first fields to review when a job creates or updates a file.

//INFILE   DD DSN=PAYROLL.INPUT.FILE,DISP=SHR
//OUTFILE  DD DSN=PAYROLL.REPORT.FILE,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(5,2)),UNIT=SYSDA

In the first line, DISP=SHR means the job is sharing an existing input file. In the second example, the job creates a new output file. If the step ends normally, z/OS catalogs it. If the step fails, z/OS deletes it.

Common DISP Values

  • OLD means the job needs exclusive access to an existing data set.
  • SHR means the job can share an existing data set.
  • NEW means the job creates a new data set.
  • MOD means the job appends to an existing data set or creates it if it does not exist.

Use OLD only when the job really needs to update the data set without another job using it at the same time. Use SHR for normal read-only input where sharing is acceptable.

RETPD And EXPDT: Retention Checks

RETPD gives a retention period in days. EXPDT gives an expiry date. Both are used to protect a data set from being removed too early. They are common on output files, archive files, and files written to tape or managed storage.

//ARCHIVE  DD DSN=PAYROLL.MONTHEND.ARCHIVE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=TAPE,
//            RETPD=90

This example asks the system to retain the archive for 90 days. A site may prefer a storage class, management class, or another local rule instead of coding retention directly in every job. Follow your site standard.

When To Use RETPD

Use RETPD when the rule is easy to express as a number of days, such as 7 days for a daily extract or 90 days for a monthly archive.

When To Use EXPDT

Use EXPDT when the business rule is tied to a date, such as a legal hold date or a fixed archive expiry date. Avoid hard-coded old dates copied from another job.

RACF: Who Can Read Or Change The Data Set

JCL does not grant security access by itself. RACF protects many kinds of z/OS data sets by using data set profiles. Those profiles can cover VSAM, non-VSAM DASD, tape data sets with standard labels, SMS-managed data sets, and GDG data sets.

A security administrator can protect a data set with a discrete profile for one data set, or a generic profile for a group of names. For example, a generic profile such as PAYROLL.** can protect many payroll data sets under the same high-level qualifier.

LISTDSD DATASET('PAYROLL.**') ALL
PERMIT 'PAYROLL.**' ID(PAYBATCH) ACCESS(READ)

The first command lists a RACF data set profile. The second command is an example of granting access. Do not run security changes unless your role and change ticket allow it.

JCL Protection Checklist Before Production

  1. Check the DSN value. Make sure the job points to the intended data set.
  2. Check DISP. Confirm whether the job should read, create, update, append, pass, catalog, or delete the data set.
  3. Check RETPD or EXPDT. Make sure the retention rule is not copied from an unrelated job.
  4. Check RACF access. Confirm the job user ID can read or update the data set profile.
  5. Check GDG use. Make sure the job uses the right generation, such as (0), (+1), or (-1).
  6. Check restart behavior. A restart can fail if the first run already cataloged a data set that the next run tries to create again.

Common Mistakes

Using DISP=OLD For Read-Only Input

DISP=OLD can block another job from using the same data set. If the program only reads the file, DISP=SHR may be the better choice.

Creating A File Twice After Restart

A failed job may leave a cataloged output data set behind. If the restart step tries DISP=(NEW,CATLG,DELETE) again, the job can fail because the data set already exists.

Copying RETPD From Another Job

A retention value copied from an old job may not match the current file. A 7-day report and a 7-year audit archive should not use the same retention rule.

Internal Reading

For related JCL topics, read JCL Tutorial: JOB, EXEC and DD Statements, JCL DD Statement, Generation Data Group in JCL, and RACF Security Audit Checklist.

FAQ

Does JCL protect a data set from unauthorized users?

No. JCL describes how a job wants to use the data set. RACF or another security product decides whether the job user ID has permission.

What is the difference between RETPD and EXPDT?

RETPD keeps a data set for a number of days. EXPDT uses a specific expiry date.

What does DISP=(NEW,CATLG,DELETE) mean?

It means the job creates a new data set, catalogs it if the step ends normally, and deletes it if the step fails.

Why does a restart fail when the job creates a data set?

The earlier run may have already cataloged the output data set. The restart then tries to create the same name again. Check the catalog and restart step before rerunning.

Before changing JCL in production, check the data set name, disposition, retention rule, RACF profile, and restart path together.

No comments:

Post a Comment

New In-feed ads