Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 2: MVS Datasets


MVS- Datasets

A data set is the mainframe word for a file. Almost everything on MVS - programs, JCL, reports, databases - is stored in data sets.

This page explains how data sets are named, how they are organized, what RECFM / LRECL / BLKSIZE mean, and how space is allocated on disk.

What is a data set

  • A data set is a collection of logically related data records stored on one disk volume or a set of volumes.
  • It can be a source program, a library of macros, or a file of records used by a processing program.
  • The basic unit of information is the logical record.
  • Most MVS data processing is record-oriented. Byte-stream files, as on PCs, are not the traditional style.
  • Data is stored on DASD (disk), magnetic tape, or optical media.

Data set naming conventions

  • A data set name is 1 to 44 characters long.
  • The name is split into qualifiers separated by periods. Maximum 22 qualifiers.
  • Each qualifier is 1 to 8 characters: letters A-Z, digits 0-9, national characters (@, #, $), and hyphen (-).
  • The first character of a qualifier must be a letter or a national character (@, #, $), never a digit.
  • The first qualifier from the left is the high-level qualifier (HLQ). The last one is the low-level qualifier (LLQ).
  • Only uppercase characters are used.
// Valid data set names AR.TRANS.Y2001 PAY.DATA.JAN05 SYS#DATA.COBOL.FILE1 MYID.JCL.FILE2 (HLQ = MYID) // Invalid data set names PAY.DATA..FEB05 (empty qualifier) AR.TRANS.Y2001. (name ends with a period) HL.ABCDEFGHIJK.DATA (qualifier longer than 8 characters) PD.123.DATA (qualifier starts with a digit)

Data set organizations

  • Sequential (PS): records stored one after another, read from beginning to end.
  • Partitioned (PO): a library of members plus a directory. Also called a PDS.
  • VSAM: advanced organization for indexed and direct access (KSDS, ESDS, RRDS, LDS).
  • Older types (indexed sequential, direct) exist but are rarely used today.

Sequential data sets

  • Records are written and read in sequential order, from the first to the last.
  • Accessed with the QSAM or BSAM access methods.
  • Typical uses: input files, report output, backup files, SYSIN/SYSOUT.
  • You cannot read record 100 without reading the 99 before it.

Partitioned data sets (PDS and PDSE)

  • A PDS is a library: one or more members plus a directory that lists the members.
  • Members are processed individually, for example one COBOL program per member.
  • Programmers store source code, JCL, and procedures in PDS libraries.
  • A member name is up to 8 characters, starting with a letter or @, #, $.
  • PDSE (partitioned data set extended) is the improved version of PDS.
  • PDSE advantages: space is reclaimed automatically when a member is deleted, flexible size, can be shared, faster directory searches.

VSAM data sets

  • VSAM = Virtual Storage Access Method. It provides more complex functions than other disk access methods.
  • KSDS (Key-Sequenced): records are accessed by a key value. Has an index component and a data component.
  • ESDS (Entry-Sequenced): records are stored in the order they are added, like a sequential file.
  • RRDS (Relative-Record): records are accessed by relative record number.
  • LDS (Linear): a byte-stream data set used by DB2 and others.
  • VSAM data is stored in control intervals, and records in a KSDS can be read sequentially, randomly by key, or dynamically (both).

Record formats: RECFM, LRECL, BLKSIZE

  • RECFM (record format) describes how records are stored. Common values:
  • F = fixed length, FB = fixed blocked, V = variable length, VB = variable blocked, U = undefined.
  • LRECL (logical record length) is the length of one record in bytes. Example: LRECL=80 for card-image records.
  • BLKSIZE (block size) is the size of the physical block written to disk.
  • Records are grouped into blocks to save space and I/O time.
  • For RECFM=FB, BLKSIZE must be an exact multiple of LRECL. Example: LRECL=80, BLKSIZE=800 means 10 records per block.
  • For variable formats, BLKSIZE must be at least LRECL + 4.

Access methods

  • An access method is the technique used to store and retrieve data.
  • QSAM (Queued Sequential Access Method): for sequential data sets.
  • BSAM (Basic Sequential Access Method): for sequential data sets, block by block.
  • BPAM (Basic Partitioned Access Method): for reading PDS members.
  • BDAM (Basic Direct Access Method): for direct access by address.
  • VSAM: for VSAM data sets.

DASD space allocation

  • Space is requested in tracks (TRK) or cylinders (CYL): one cylinder = 15 tracks.
  • SPACE=(TRK,(primary,secondary,directory)): primary is the first extent, secondary is added if the data set grows, directory is the number of directory blocks for a PDS.
  • Space is assigned in extents (contiguous pieces of a volume).
  • One DASD volume can hold many data sets, and free space is reused.
  • With SMS (System-Managed Storage), a data class can supply the space values automatically.

Ways to allocate a data set

  • ISPF data set panel, option 3.2 (allocate new data set).
  • TSO ALLOCATE command.
  • JCL DD statement with DISP=(NEW,...).
  • IDCAMS (Access Method Services) for VSAM.
// JCL: allocate a new sequential data set //ALLOCPS EXEC PGM=IEFBR14 //NEWPS DD DSN=MYID.TEST.PSFILE, // DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA, // SPACE=(TRK,(5,2)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) // JCL: allocate a new PDS (20 directory blocks) //ALLOCPDS EXEC PGM=IEFBR14 //NEWPDS DD DSN=MYID.TEST.PDSLIB, // DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA, // SPACE=(TRK,(10,5,20)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) // TSO: allocate the same sequential data set ALLOCATE DSN('MYID.TEST.PSFILE') NEW TRACKS SPACE(5,2) - DSORG(PS) RECFM(F,B) LRECL(80) BLKSIZE(800) CATALOG

Define a VSAM KSDS with IDCAMS

  • VSAM data sets are created with the IDCAMS DEFINE CLUSTER command.
  • KEYS(length offset) gives the key length and its position in the record.
  • RECORDSIZE(average maximum) gives the record size.
  • The cluster name is what programs use; the DATA and INDEX names are its components.
//DEFVSAM JOB (ACCT),'DEFINE KSDS',CLASS=A,MSGCLASS=X //STEP1 EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //SYSIN DD * DEFINE CLUSTER(NAME(MYID.VSAM.CUSTFILE) - VOLUMES(VOL001) - RECORDSIZE(80 80) - KEYS(10 0) - INDEXED) - DATA(NAME(MYID.VSAM.CUSTFILE.DATA)) - INDEX(NAME(MYID.VSAM.CUSTFILE.INDEX)) /*

The VTOC

  • The VTOC (Volume Table of Contents) sits on every DASD volume.
  • It lists all data sets on the volume and all free space.
  • It holds DSCBs (Data Set Control Blocks): labels with each data set's name and location.
  • Every volume also has a VOL1 label with the volume serial number (volser).





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant