DEFINE CLUSTER is the IDCAMS command that creates a new VSAM cluster. When you run it, IDCAMS allocates space on DASD, creates the catalog entry (or entries) for the cluster and its components, and sets the attributes you specify: organization type (KSDS, ESDS, RRDS, or LDS), record size, key (for KSDS), free space, and allocation. You cannot create a VSAM dataset with JCL DISP=NEW the way you do for sequential files; DEFINE CLUSTER is the standard way. This page explains the DEFINE CLUSTER syntax, the main parameters, and how to define each type of VSAM dataset.
When IDCAMS processes a DEFINE CLUSTER command, it creates one logical object—the cluster—and one or two component objects. For a KSDS (INDEXED), it creates the data component and the index component. For ESDS, RRDS, or LDS, it creates only the data component. The cluster name is what you use in JCL (DSN=) and in application programs. The components are internal; you do not open them directly. DEFINE CLUSTER also allocates space: you specify how much (in cylinders, tracks, or records) and optionally which volume(s). After a successful DEFINE, the cluster is cataloged and ready to be opened, loaded (e.g. with REPRO), and used by programs.
The command starts with DEFINE CLUSTER and is followed by cluster-level parameters, then optionally DATA(...) and for KSDS INDEX(...). Parameters are keyword(value) or keyword. Continuation across lines uses a hyphen at the end of the line. A minimal form is:
12345678DEFINE CLUSTER ( - NAME(cluster-name) - organization - RECORDSIZE(min max) - space-allocation) - [ DATA (...) ] - [ INDEX (...) ] /* KSDS only */
Organization is one of INDEXED, NONINDEXED, NUMBERED, or LINEAR. Space allocation is CYLINDERS(primary secondary), TRACKS(primary secondary), or RECORDS(primary secondary). For KSDS you also specify KEYS(length offset). The following sections describe the main parameters in more detail.
You must specify exactly one organization type. It determines the dataset type and what components are created.
| Keyword | Dataset type | Description |
|---|---|---|
| INDEXED | KSDS | Key Sequenced Data Set. Has data and index components. Records in key order; access by key or sequentially. Supports insert, delete, update. |
| NONINDEXED | ESDS | Entry Sequenced Data Set. Data component only. Records in entry order; access by RBA or sequential. No physical delete; append-only. |
| NUMBERED | RRDS | Relative Record Data Set. Data component only. Fixed-length records in slots; access by relative record number (RRN) or sequentially. |
| LINEAR | LDS | Linear Data Set. Byte-addressable; no record structure. Used by products like Db2; not used for normal application record I/O. |
INDEXED is used for keyed files where you need direct access by key and sequential access in key order. NONINDEXED is for entry-sequenced files (logs, history) where records are appended and accessed by position (RBA) or sequentially. NUMBERED is for fixed-length records accessed by relative record number. LINEAR is for special uses (e.g. LDS for Db2) and is not used for normal record I/O.
These parameters appear on almost every DEFINE CLUSTER. NAME identifies the cluster. RECORDSIZE defines the record layout. KEYS is required for KSDS. FREESPACE and space allocation control how much space is reserved and how much is allocated.
| Parameter | Description |
|---|---|
| NAME(cluster-name) | The name of the cluster (up to 44 characters). This is the name you use in JCL and programs. Required. |
| INDEXED | NONINDEXED | NUMBERED | LINEAR | Organization type. Exactly one is required. Determines whether you get KSDS, ESDS, RRDS, or LDS. |
| RECORDSIZE(min max) | Minimum and maximum record length in bytes. For fixed-length records, use the same value twice (e.g. RECORDSIZE(80 80)). |
| KEYS(length offset) | For KSDS only. Key length in bytes and offset from the start of the record (e.g. KEYS(10 0) for a 10-byte key at position 0). |
| FREESPACE(ci-percent ca-percent) | Percentage of each control interval and control area reserved for inserts (KSDS, RRDS). Reduces splits. ESDS/LDS do not use FREESPACE the same way. |
| CYLINDERS(primary secondary) | Space in cylinders. Primary is initial allocation; secondary is each extension. Alternative: TRACKS or RECORDS. |
| VOLUMES(volser) | DASD volume serial(s) where the cluster is allocated. Omit if SMS manages placement. |
| SHAREOPTIONS(cross-region cross-system) | Sharing rules. (1 3) allows read/write sharing; (2 3) is common for batch; (3 3) restricts sharing. Affects when the file can be opened by multiple jobs or regions. |
| REUSE / NOREUSE | REUSE allows the cluster to be redefined (emptied and reused) without deleting it. NOREUSE is the default. |
| DATA(...) / INDEX(...) | Optional. Subparameters to name or qualify the data and index components. Omit to use defaults. |
RECORDSIZE(min max) gives the minimum and maximum record length in bytes. For fixed-length records (common for KSDS and RRDS), code the same value twice, e.g. RECORDSIZE(80 80) or RECORDSIZE(200 200). For variable-length records, min and max define the allowed range; for example RECORDSIZE(50 500) allows records from 50 to 500 bytes. These values cannot be changed after the cluster is defined.
KEYS(length offset) applies only to INDEXED (KSDS). Length is the key length in bytes; offset is the position of the first byte of the key within the record (0-based). For example KEYS(10 0) means a 10-byte key starting at byte 0; KEYS(8 20) means an 8-byte key starting at byte 20. The key must lie entirely within the record (offset + length ≤ record length). Key length and offset are fixed at define time.
You specify space with CYLINDERS(primary secondary), TRACKS(primary secondary), or RECORDS(primary secondary). Primary is the amount allocated when the cluster is created. When the cluster fills, VSAM extends it by the secondary amount (up to a limit, often 123 extensions). CYLINDERS is common for larger files; TRACKS for smaller; RECORDS for very small or when you want to allocate by record count. Example: CYLINDERS(10 5) allocates 10 cylinders initially and 5 cylinders per extension.
FREESPACE(ci-percent ca-percent) reserves a percentage of each control interval and each control area for new records. This is used by KSDS and RRDS to reduce how often VSAM has to split control intervals or control areas when inserting. For example FREESPACE(20 10) reserves 20% of each CI and 10% of each CA. Higher values mean more room for inserts but less data per CI (more I/O for sequential reads). ESDS does not use FREESPACE in the same way because it only appends; LDS has no record structure.
The DATA clause lets you specify the data component name and optionally other data-component attributes. The INDEX clause (KSDS only) lets you specify the index component name and attributes. If you omit them, IDCAMS generates default names (usually cluster-name.DATA and cluster-name.INDEX). Explicit names are useful when you want to recognize components in LISTCAT or when following naming standards. Example:
1234567891011DEFINE CLUSTER ( - NAME(MY.APPL.KSDS) - INDEXED - RECORDSIZE(100 100) - KEYS(12 0) - FREESPACE(15 10) - CYLINDERS(20 5) - SHAREOPTIONS(2 3)) - DATA (NAME(MY.APPL.KSDS.DATA)) - INDEX (NAME(MY.APPL.KSDS.INDEX))
This defines a KSDS named MY.APPL.KSDS with 100-byte fixed records, a 12-byte key at offset 0, 15% CI and 10% CA free space, 20 cylinders primary and 5 secondary, and share options (2 3). The data and index components are explicitly named.
For an Entry Sequenced Data Set use NONINDEXED. There is no KEYS parameter. You still specify RECORDSIZE and space. There is no INDEX clause.
1234567DEFINE CLUSTER ( - NAME(MY.LOG.ESDS) - NONINDEXED - RECORDSIZE(256 256) - CYLINDERS(5 2)) - DATA (NAME(MY.LOG.ESDS.DATA))
ESDS records are fixed or variable within RECORDSIZE; they are stored in the order they are written and cannot be physically deleted. Access is by RBA or sequential.
For a Relative Record Data Set use NUMBERED. Records are fixed-length; each slot has a relative record number (RRN). You specify RECORDSIZE (same min and max for fixed length) and space. FREESPACE can be used to leave empty slots for later inserts.
12345678DEFINE CLUSTER ( - NAME(MY.RRDS.FILE) - NUMBERED - RECORDSIZE(80 80) - FREESPACE(10 5) - TRACKS(10 5)) - DATA (NAME(MY.RRDS.FILE.DATA))
VOLUMES(volser) specifies the DASD volume serial(s) when you need to place the cluster on particular volumes. SHAREOPTIONS(cross-region cross-system) controls how the file can be shared (e.g. (2 3) for typical batch). REUSE allows the cluster to be opened for output and rewritten without deleting it first. READPW and UPDATEPW add password protection. FOR(days) or TO(date) set retention. CATALOG(catalog-name[/password]) specifies which catalog to use. Your installation may have standards for these.
DEFINE CLUSTER is like ordering a new filing cabinet. You tell the system what kind of cabinet (with keys, or just in order, or with numbered drawers), how big the folders (records) are, how much space you want, and what to call it. The system finds space on the disks, writes down the name in the catalog, and from then on you can open that cabinet and put in or read data. You cannot change the folder size or the key type later—you would have to get a new cabinet and move the data.
1. Which keyword creates a KSDS?
2. What does RECORDSIZE(100 200) mean?
3. Can you ALTER a cluster to change its KEYS?