VSAMintermediate

IDCAMS: DEFINE CLUSTER and REPRO

Gain hands-on fluency with IDCAMS control statements for defining VSAM clusters and moving data into or out of them.

IDCAMS handles the VSAM lifecycle. Two commands come up often enough to write from memory.

DEFINE CLUSTER is pouring the foundation and framing for a new building according to a blueprint (organization, key layout, space allocation); REPRO is the moving company that then carries furniture in, out, or between buildings, but insists that if you're moving into an alphabetically organized library (a KSDS), the boxes must already be in the right order before they'll carry them in.

Key Concepts

1
DEFINE CLUSTER creates the file, and its parameters are the design decisions:
2
    DEFINE CLUSTER (NAME(PROD.CUSTOMER.KSDS) -
                    INDEXED -
                    KEYS(9 0) -
                    RECORDSIZE(200 200) -
                    FREESPACE(20 10) -
                    CYLINDERS(50 10) -
                    SHAREOPTIONS(2 3)) -
           DATA  (NAME(PROD.CUSTOMER.KSDS.DATA)) -
           INDEX (NAME(PROD.CUSTOMER.KSDS.INDEX))
3
    INDEXED       KSDS.  NONINDEXED = ESDS.  NUMBERED = RRDS.
    KEYS(9 0)     the key is 9 bytes, starting at offset 0
    RECORDSIZE    average and maximum record length
    FREESPACE     percent free in each CI and CA, for future inserts
    CYLINDERS     primary and secondary space
4
KEYS(9 0) is offset-based and zero-based, which catches people out. A key starting in position 10 of the record is offset 9, not 10.
KEYS(9 0)
5
FREESPACE cannot be changed later without redefining and reloading the cluster, which is why getting it right at definition time matters. Zero free space on a file that will be inserted into guarantees splits from the first day.
FREESPACE
6
REPRO moves data.
    REPRO INFILE(SEQIN) OUTFILE(VSAMOUT)        load from a flat file
    REPRO INFILE(VSAMIN) OUTFILE(SEQOUT)        extract to a flat file
    REPRO INDATASET(A) OUTDATASET(B)            cluster to cluster
7
Input to a KSDS must already be in key order. REPRO does not sort. Feeding it unsorted input fails part way through, having loaded everything up to the first out-of-order record.
8
So the usual pattern is a DFSORT step first, then REPRO.
9
The two companions.LISTCAT shows what the catalog knows — allocated against used space, the high-used RBA, and the number of CI and CA splits. That split count is how you tell a cluster needs reorganising, and it is the first thing to look at when a VSAM file has become slow.
LISTCAT
10
    LISTCAT ENTRIES(PROD.CUSTOMER.KSDS) ALL
11
DELETE removes a cluster and its catalog entry.
DELETE
12
One operational note. DELETE on a cluster that does not exist returns condition code 8, failing the step even though the outcome you wanted — no such dataset — is exactly what you have. That is why define and delete steps usually carry a maximum condition code setting.
DELETE
13
What the interviewer is probing.1. "What does DEFINE CLUSTER create?" Probing: the basics. Stalls: "A file." Moves up: the VSAM cluster — the data component and, for a KSDS, the index component, with its space, key position and free space parameters.
14
2. "What is REPRO used for?" Probing: the breadth. Stalls: "Copying." Moves up: copying between datasets in either direction, which is how VSAM files are loaded, backed up and reorganised.
15
3. "How do you reorganise a KSDS with IDCAMS?" Probing: the procedure. Stalls: "REORG." Moves up: REPRO out to a sequential file, DELETE and DEFINE the cluster, then REPRO back — which rebuilds it in key order with fresh free space.
16
4. "What does the VERIFY command fix?" Probing: practical knowledge. Stalls: "Corruption." Moves up: a cluster left open after an abend, by correcting the end-of-file information so it can be opened normally.