Skip to content
systemcoding.dev
Mainframe

Allocate New Datasets in JCL With SPACE and DCB

Create a new z/OS dataset in JCL with UNIT, SPACE, DCB and DSORG: primary and secondary space, RECFM and LRECL, and BLKSIZE=0 for the system block size.

6 min read
Summarize in AI
Flat illustration of a 3270 terminal showing JCL beside a mainframe.

Creating a dataset on z/OS means answering questions that a PC file system never asks: where it should live, how much room it may use, how records are laid out, and how they are grouped into blocks on disk. In JCL the answers go in the DD statement of the step that creates the dataset, in UNIT, SPACE and DCB. This post shows how each works on z/OS 3.1, how to size space without guessing wildly, what the record format letters mean, and the failures that follow from getting them wrong. It builds on the DISP parameter, since DISP=(NEW,CATLG,DELETE) is how a new dataset is requested in the first place.

A complete allocation

ALLOC.jcljcl
//ALLOC    JOB (ACCT),'ALLOCATE',CLASS=A,MSGCLASS=X
//STEP1    EXEC PGM=IEFBR14
//NEWFILE  DD DSN=STUDENT1.CUSTOMER.DATA,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(5,2),RLSE),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)

IEFBR14 is a program that does nothing and returns immediately. Its only effect is that the system allocates every DD statement before it runs, so it is the standard way to create or delete datasets from JCL. After this job, STUDENT1.CUSTOMER.DATA exists and is cataloged, empty.

UNIT

UNIT tells the system what kind of device to use. SYSDA is a conventional name for a generic group of direct access (disk) devices, and the installation defines what it contains. On systems managed by SMS, the storage group and class rules often choose the real volume, and UNIT mainly signals the type. Use the value your site documents, and do not code VOL=SER= unless you must place the dataset on a specific volume.

SPACE

SPACE has three parts: the unit of allocation, the quantities, and options.

SPACE.jcljcl
//         SPACE=(CYL,(5,2),RLSE)
//         SPACE=(TRK,(10,5,20))
//         SPACE=(80,(1000,500),RLSE),AVGREC=U

The first position names the unit: TRK for tracks, CYL for cylinders, or a number that is the average record length in bytes. A cylinder on a 3390 device holds 15 tracks, so CYL allocations are larger steps than TRK.

The first number in the parentheses is the primary quantity, allocated when the dataset is created. The second is the secondary quantity, requested each time the dataset fills the space it has, up to a limit of extents. A dataset may grow in several extents, so a modest primary with a secondary of similar size is a common pattern. The third number, used only for partitioned datasets, is the count of directory blocks, the space for the member index; it is needed for a PDS and omitted for a sequential file.

RLSE, release, tells the system to give back unused space when the dataset is closed after being written, which trims an overestimate to size.

When the first position is a record length, as in SPACE=(80,(1000,500)), the quantities count records, and AVGREC=U says they are in units of one record (K for thousands and M for millions). That is the easiest form for a programmer who knows the number of records and not the device geometry, and the system converts to tracks.

Sizing sensibly

Space estimates need not be exact, but they should come from a calculation. A fixed-block dataset holds records of LRECL bytes. For 100,000 records of 80 bytes, the data is 8,000,000 bytes. A track on a 3390 holds about 56,000 bytes when blocked well, so the dataset needs roughly 8,000,000 divided by 56,000, about 143 tracks, that is about ten cylinders, with a margin. Rounding up costs little and an allocation that is too small costs a failed job, but a primary far larger than needed wastes shared space even with RLSE.

The failure when space runs out is an x37 abend: B37 when the volume has no room for the next extent, D37 when the primary space fills and no secondary was coded, and E37 when the dataset has used its maximum number of extents or volumes. If your job ends with one of these, the fix is a larger or better placed allocation, not a rerun.

DCB: the shape of the records

DCB, data control block, describes the records. Its common subparameters are three.

SubparameterMeaning
RECFMRecord format: F fixed, V variable, U undefined, with B blocked and A for ASA carriage control
LRECLLogical record length in bytes
BLKSIZEBlock size in bytes, the unit read and written on disk

RECFM=FB means fixed records grouped into blocks, with LRECL the length of each record. RECFM=VB is variable records in blocks, and then LRECL includes four bytes for a record descriptor word, as the COBOL posts on this site explain. RECFM=FBA has a carriage control character in column one of each record, for print files.

BLKSIZE=0 asks the system to determine the best block size for the device, which is what you almost always want. Hard-coding a block size ties the dataset to one device geometry and tends to waste space on another. A block size must be a multiple of the record length for fixed records, and the system takes care of that when it chooses.

DSORG states the dataset organization: PS for physical sequential, PO for partitioned. With DSORG=PO the third SPACE number or a DSNTYPE=LIBRARY request for a PDSE is also needed. The allocation of a PDSE is written with DSNTYPE=LIBRARY, for which the directory quantity is not required.

Letting the system or the shop decide

Many installations use SMS classes to set these for you. DATACLAS= names a data class that supplies defaults for record format, length, space and more; STORCLAS= names the storage class; MGMTCLAS= names the management class. With a good data class a DD statement can shrink to a name and a disposition. You can also copy attributes from an existing dataset, which avoids retyping and mistakes:

LIKE.jcljcl
//NEWFILE  DD DSN=STUDENT1.CUSTOMER.COPY,
//             DISP=(NEW,CATLG,DELETE),
//             LIKE=STUDENT1.CUSTOMER.DATA

LIKE= takes the space and attributes of the model dataset. Keep a model dataset for each standard shape you use, and the allocations in your jobs become one line long.

Confirming the result

The job log reports the allocation:

Text
IEF142I ALLOC STEP1 - STEP WAS EXECUTED - COND CODE 0000
IEF285I   STUDENT1.CUSTOMER.DATA                       CATALOGED

To check the attributes, open ISPF option 3.2 and enter the dataset name with I for information. It displays the record format, the record length, the block size, the organization, and the space used. Compare them with what you coded. If the block size is not what you expected, the system chose it, which is the point of BLKSIZE=0.

When this does not fit

VSAM datasets are not created with DCB and SPACE on a DD. They are defined with the IDCAMS DEFINE CLUSTER command, which has its own space and attribute parameters. Temporary datasets named &&NAME use the same parameters but are deleted at the end of the job. Very large datasets that span volumes need extended format and the installation's guidance, including the maximum number of extents, which depends on the dataset type.

Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.