ALLOCATE
Creates a new dataset and puts its name in the catalog.
Also written ALLOC
Why it matters. Everything you build starts as an empty dataset. ALLOCATE is how you make one.
See it
Read it left to right
- ALLOC
- Make a dataset
- DSN('…')
- Its name, in brackets and quotes
- NEW
- A new one
- DSORG(PO)
- A library. DSORG(PS) for a single file
- DIR(5)
- Room for the library's list of members
- SPACE(1,1) TRACKS
- One track to start, one more each time it fills
Syntax
{ALLOCATE | ALLOC} {DATASET | DSNAME}(dsname) [OLD | SHR | MOD | NEW]
ALLOCATE ... [DSORG(PS | PO)] [RECFM(FB)] [LRECL(n)] [BLKSIZE(n)] [SPACE(primary,secondary) TRACKS | CYLINDERS] [DIR(n)] [FILE(ddname)] [LIKE(model-dsname)]- DATASET(dsname)
- The dataset name. DA and DSN are the short forms. Quote the name. A library member can go in brackets.
- NEW
- Make a new dataset. Without it, ALLOCATE looks for one that exists (OLD, SHR or MOD).
- DSORG(PS | PO)
- PS is a plain sequential file. PO is a library with members.
- SPACE(primary,secondary)
- How much disk to ask for. Add TRACKS or CYLINDERS to say the unit.
- DIR(n)
- Directory blocks for a library (PO). It is needed unless a data class supplies a default.
- RECFM, LRECL, BLKSIZE
- Record format, record length and block size. FB with LRECL(80) is usual for JCL and source.
- LIKE(model)
- Copy the attributes of an existing cataloged dataset.
- FILE(ddname)
- The file name (ddname) the dataset is connected to for this session.
Try it ALLOCATE
- 1
Create a library called ZB0001.DEV.JCL that can hold members.
ALLOC DSN('ZB0001.DEV.JCL') NEW DSORG(PO) DIR(5) SPACE(1,1) TRACKS - 2
Now create a plain file called ZB0001.DATA.
ALLOC DSN('ZB0001.DATA') NEW DSORG(PS) SPACE(1,1) TRACKS - 3
Run the same command again, to see what happens when the name is taken.
ALLOC DSN('ZB0001.DATA') NEW DSORG(PS) SPACE(1,1) TRACKS
Remember
- NEW makes a new dataset. Without it, ALLOCATE looks for one that exists.
- DSORG(PS) is one file. DSORG(PO) is a library of members.
- Names are unique. A second ALLOCATE of the same name fails.
The usual mistake
ALLOC DSN('ZB0001.DATA') DSORG(PS)
Without NEW, ALLOCATE looks for a dataset that is already there. It does not create one.
ALLOC DSN('ZB0001.DATA') NEW DSORG(PS) SPACE(1,1) TRACKS
On real z/OS
MF/OS shows a 'Mainframe101 sim:' note when a new dataset is made; real TSO prints nothing. The storage-class operands (DATACLAS, MGMTCLAS, STORCLAS) and tape operands are not modelled, so every dataset lands on the simulator's own disk, RES001. IGD17101I is an SMS message, so it appears on systems where SMS manages the dataset.
Where can I practise ALLOCATE?
Right here, at ZedBank. You take a junior job at a simulated bank and use ALLOCATE in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- DatasetWhat a mainframe calls a file: a named collection of records with a defined structure, rather than a loose stream of bytes.
- CatalogThe system's index of where datasets live, so you can refer to a dataset by name without knowing which disk it is on.
- Partitioned datasetA dataset that works like a library or folder, holding many separately named members inside one dataset.
- High-level qualifierThe first part of a dataset name, which usually identifies the owner and drives how security and storage rules apply.
- TSOTime Sharing Option: the interactive login environment on z/OS, where you get a command prompt and a session of your own.