MainframeMaster

JCL Tutorial

Space Allocation

Understanding how to allocate and manage space for datasets in JCL

Progress0 of 0 lessons

Introduction to Space Allocation

When creating new datasets in JCL, you must specify how much disk space should be allocated. The SPACE parameter on the DD statement is used to define the amount of space to be allocated to a dataset. Proper space allocation is crucial for efficient use of storage resources and to ensure that your datasets have enough room to store all required data.

This tutorial covers the SPACE parameter in detail, including allocation units, primary and secondary allocation, directory blocks for partitioned datasets, and additional options that control how space is allocated and managed.

SPACE Parameter Syntax

The SPACE parameter is required when creating a new dataset (DISP=NEW) and specifies how much disk space should be allocated. It has several subparameters that control different aspects of space allocation.

Basic Syntax:

jcl
1
2
//ddname DD DSN=dataset.name,DISP=(NEW,CATLG,DELETE), // SPACE=(allocation-unit,(primary,secondary,directory))

The key components of the SPACE parameter are:

  • Allocation Unit - Specifies the unit of measurement for space allocation (TRK, CYL, or block size)
  • Primary Allocation - The initial amount of space allocated
  • Secondary Allocation - Additional space to be allocated if the primary allocation is filled
  • Directory Blocks - For partitioned datasets, specifies the number of directory blocks
  • Additional Options - RLSE, CONTIG, ROUND, etc.

Allocation Units

The first subparameter of the SPACE parameter specifies the unit of measurement for space allocation. There are three main types of allocation units:

TRK (Tracks)

Allocates space in terms of disk tracks. A track is a physical unit of storage on a disk device. The size of a track depends on the device type, but it's typically around 56KB for common disk types.

jcl
1
2
//DDTRK DD DSN=USER.TRACKS.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(10,5))

This example allocates 10 tracks initially, with 5 additional tracks available as secondary allocation.

CYL (Cylinders)

Allocates space in terms of disk cylinders. A cylinder consists of a set of tracks (typically 15) and is a larger unit of allocation. Using cylinders can improve performance for larger datasets.

jcl
1
2
//DDCYL DD DSN=USER.CYLS.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(2,1))

This example allocates 2 cylinders initially, with 1 additional cylinder available as secondary allocation.

Block Size

Instead of using TRK or CYL, you can specify the average block size (in bytes). The system will calculate the appropriate number of tracks or cylinders to allocate based on the block size and quantity.

jcl
1
2
//DDBLK DD DSN=USER.BLOCKS.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(800,(100,50))

This example specifies that the average block size is 800 bytes, and requests space for 100 such blocks initially, with space for 50 additional blocks available as secondary allocation.

Best Practice:

For most general-purpose datasets, TRK is a good choice for allocation. For larger datasets, CYL often provides better performance. Using block size can provide more precise control but requires more calculation and understanding of the device characteristics.

Primary and Secondary Allocation

The SPACE parameter includes specifications for both primary and secondary allocation.

Primary Allocation

Primary allocation is the initial amount of space allocated when the dataset is created. This space is reserved in a contiguous manner if possible. You should allocate enough primary space to handle the expected data volume under normal conditions.

Secondary Allocation

Secondary allocation specifies how much additional space to allocate if the dataset fills up. When the primary allocation is filled, the system will allocate secondary space in the amount specified. This can happen multiple times as needed, up to a system-defined limit (typically 16 extents, though modern systems often allow more).

Example:

jcl
1
2
3
4
//DD1 DD DSN=USER.PS.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(50,20)) //DD2 DD DSN=USER.SMALL.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(1,1))

In the first example, 50 tracks are allocated initially, with 20 additional tracks allocated each time the dataset needs to expand. In the second example, 1 cylinder is allocated initially, with 1 additional cylinder allocated if needed.

Important:

Secondary allocations are not guaranteed to be contiguous with the primary allocation or with each other. Each secondary allocation creates a new "extent" of the dataset, which can impact performance if there are many extents.

Space Calculation Strategy

To calculate the appropriate space allocation, consider:

  • The record length (LRECL) of your dataset
  • The estimated number of records
  • The block size (BLKSIZE) if blocking is used
  • Expected growth over time

A common approach is to allocate enough primary space for the immediate needs with a reasonable safety margin, and then specify a secondary allocation of about 20-30% of the primary allocation.

Directory Blocks for PDS

When creating a Partitioned Data Set (PDS), you must specify the number of directory blocks to allocate. Directory blocks store the information about the members of the PDS, including their names and locations.

Syntax for PDS:

jcl
1
2
//PDSDEMO DD DSN=USER.PDS.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(10,5,5))

In this example, 5 directory blocks are allocated (the third value in the SPACE parameter). Each directory block can hold approximately 5-6 member entries, depending on the length of the member names and other factors.

Calculation Tip:

As a rule of thumb, allocate one directory block for every 5-6 members you expect to have in the PDS. For example, if you expect to have 30 members, allocate at least 6 directory blocks.

Warning:

Once a PDS is created, the number of directory blocks cannot be changed without recreating the dataset. If you run out of directory blocks, you won't be able to add more members to the PDS even if there is plenty of data space available.

Additional SPACE Options

The SPACE parameter has several additional options that can be used to control how space is allocated and managed.

RLSE (Release)

The RLSE option instructs the system to release any unused space when the dataset is closed. This can help optimize disk usage by returning unused space to the system.

jcl
1
2
//DDRLSE DD DSN=USER.RELEASE.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(100,50),RLSE)

In this example, if the dataset uses less than the allocated 100 tracks, the unused space will be released when the dataset is closed.

CONTIG (Contiguous)

The CONTIG option requests that the primary allocation be in contiguous tracks or cylinders. If contiguous space is not available, the allocation will fail.

jcl
1
2
//DDCONT DD DSN=USER.CONTIG.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,2),,,CONTIG)

Note the use of commas to skip optional parameters between the allocation values and CONTIG.

ROUND

When using average block length for allocation, the ROUND option rounds the space allocation up to a complete cylinder. This can improve performance for certain types of applications.

jcl
1
2
//DDRND DD DSN=USER.ROUND.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(800,(1000,500),,,ROUND)

ALX (All Extents)

The ALX option requests that up to five separate contiguous areas (extents) be allocated for the primary allocation of the dataset. This is useful when a large contiguous area isn't available.

jcl
1
2
//DDALX DD DSN=USER.ALX.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,5),,,ALX)

MXIG (Maximum Contiguous Space)

The MXIG option requests allocation of the largest contiguous area of available space. The amount requested is treated as a minimum rather than an exact amount.

jcl
1
2
//DDMXIG DD DSN=USER.MXIG.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(50,10),,,MXIG)

Space Calculation Strategies

Calculating the appropriate space allocation requires understanding the data characteristics and usage patterns. Here are some approaches to help determine the right space allocation:

Sequential Datasets

For sequential datasets, calculate the space needed based on:

  1. Record length (LRECL) × Number of records = Total data size
  2. If blocking is used, calculate:
    Number of blocks = ⌈Total data size ÷ Block size⌉
  3. Convert to tracks or cylinders based on device characteristics:
    Number of tracks = ⌈Number of blocks × Block size ÷ Track capacity⌉

Example Calculation:

For a dataset with:

  • LRECL = 80 bytes
  • Expected records = 10,000
  • Block size = 800 bytes (10 records per block)
  • Track capacity = 56KB (approximately)

Total data size = 80 × 10,000 = 800,000 bytes
Number of blocks = ⌈800,000 ÷ 800⌉ = 1,000 blocks
Space required = ⌈1,000 × 800 ÷ 56,000⌉ = 15 tracks

With a safety margin and growth consideration, you might allocate:
SPACE=(TRK,(20,10))

Partitioned Datasets (PDS)

For a PDS, you need to consider both the data space and directory space:

  1. Calculate the total data space as for sequential datasets, considering all members
  2. Calculate directory blocks: Number of members ÷ 5 (rounded up)

Example PDS Calculation:

For a PDS with:

  • Expected members = 25
  • Average member size = 100 records of 80 bytes
  • Total records = 25 × 100 = 2,500
  • Directory blocks needed = ⌈25 ÷ 5⌉ = 5

Using the same calculation as above for data space, with a safety margin:
SPACE=(TRK,(10,5,5))

Frequently Asked Questions

Test Your Knowledge

1. Which of the following is NOT a valid allocation unit in the SPACE parameter?

  • TRK
  • BLOCK
  • CYL
  • A numeric value representing average block size

Answer: BLOCK (The valid options are TRK, CYL, or a numeric value for block size)

2. In the SPACE parameter SPACE=(TRK,(100,50,10)), what does the "10" represent?

  • The number of directory blocks (for a PDS)
  • The maximum number of extents
  • The percentage of free space to maintain
  • The block size in KB

Answer: The number of directory blocks (for a PDS)

3. What happens if a PDS runs out of directory blocks but still has data space available?

  • The system will automatically allocate more directory blocks
  • You can add more directory blocks using a utility
  • You cannot add more members even if data space is available
  • The job will switch to using secondary allocation for directory blocks

Answer: You cannot add more members even if data space is available

4. Which SPACE option releases unused space when the dataset is closed?

  • FREE
  • RLSE
  • RELEASE
  • UNUSED

Answer: RLSE

5. Write a JCL statement to allocate a new PDS with 5 cylinders of primary space, 1 cylinder of secondary space, and 10 directory blocks. The dataset should be cataloged if successful or deleted if the job fails.

Answer:
//NEWPDS DD DSN=USER.NEW.PDS,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,1,10))