Showing posts with label z OS data sets. Show all posts
Showing posts with label z OS data sets. Show all posts

Saturday, 10 August 2013

JCL Spanned Records: RECFM=VBS, LRECL=X, and Safe Usage

A JCL DD statement with DCB=(RECFM=VBS,LRECL=X) tells z/OS that a logical record may be too large to fit in one physical block. The record is still one record to the program, but the access method can store it as segments across more than one block.

JCL spanned records diagram showing one logical record split across two blocks with RECFM VBS and LRECL X
One record can span blocks.

What is a spanned record in JCL?

A spanned record is a variable-length logical record that is stored in pieces when the full record does not fit into a single block. You normally see this on sequential data sets that carry long business records, large print records, XML-like payloads, or converted reports where one logical row can grow past the normal block boundary.

In everyday batch work, most files use FB or VB. A fixed blocked file has the same record length on every row. A variable blocked file can hold records of different sizes, but each logical record still fits inside a block. A spanned variable file, commonly coded as VBS, allows one logical record to continue into the next block when needed.

When should you use RECFM=VBS?

Use RECFM=VBS only when the application has a real need for very long variable records. It is not a default choice for normal transaction files, control files, extract files, or small report feeds. If every record is short enough for a normal VB file, keeping RECFM=VB is simpler and easier for downstream jobs to handle.

Record format Meaning Common use
FB Fixed blocked records Flat files where every record has the same length
VB Variable blocked records Files where records have different lengths but fit inside a block
VBS Variable blocked spanned records Files where one logical record may need more than one block

JCL example for a spanned record data set

The DD statement usually carries the record format in the DCB parameter. Existing shops may also let SMS data classes supply these attributes, so check local standards before hard-coding every value.

//STEP010  EXEC PGM=MYPROG
//OUTFILE  DD  DSN=PROD.REPORT.LONGREC,
//             DISP=(NEW,CATLG,DELETE),
//             SPACE=(CYL,(20,10),RLSE),
//             DCB=(RECFM=VBS,LRECL=X)

The LRECL=X part is used for QSAM when the logical record length can be greater than 32,760 bytes. That is the detail many short notes miss. Without it, someone may copy RECFM=VBS into a job and still fail when the record length is not described correctly for the access method and program.

How RDW, BDW, and segments fit together

Variable records include a record descriptor word, usually called an RDW. Variable blocked records also use a block descriptor word, usually called a BDW, at the start of a block. In a spanned file, z/OS needs extra segment information so it can rebuild the logical record correctly when the record has been split across blocks.

For a COBOL or assembler program, the useful rule is simple: the program should process the logical record, not guess at physical block pieces. If a program reads the file through the normal access method, it should receive the data according to the file definition and program definition. Problems usually appear when a utility, copy program, FTP setup, or downstream reader assumes ordinary VB records.

Why DISP=MOD can be risky with spanned records

The old warning about DISP=MOD is worth keeping. Appending to a spanned-record data set can introduce short-block behavior that surprises later processing. If a job must add more records, the safer pattern is often to create a new output data set and copy or merge the old and new data with a controlled utility step.

//BADAPPND DD DSN=PROD.REPORT.LONGREC,
//            DISP=MOD
//*
//* Better: build a new output generation, then replace by standard process.

That approach also gives operations a cleaner restart point. A failed append can leave the support team asking whether the last logical record was complete, whether the block was closed correctly, and which downstream job consumed the partial file.

Checks before using a spanned record file

Before moving this kind of file into production, check the data set attributes, the program definition, and every job that reads the file. One weak reader in a later step can turn a good file design into a late-night incident.

  • Confirm that the producing program really needs records larger than a normal variable blocked file can handle.
  • Check whether the consumer supports RECFM=VBS, especially sort, copy, transfer, reporting, and unload steps.
  • Use a naming standard or comment that tells support staff why the file is spanned.
  • Avoid casual append processing with DISP=MOD.
  • Test the longest realistic record, not only a small sample file.

Common mistakes

Using VBS for a normal file

Some developers use VBS because it sounds more flexible than VB. That adds a special case where none is needed. If the largest record is comfortably within the normal limit, VB is usually easier for utilities and support teams.

Forgetting the downstream jobs

A file may be created correctly and still fail in a later step. Check any JCL SORT, copy, archive, and transfer process that reads the data set.

Copying only the DCB line

The DCB line is only one part of the design. Space allocation, restart rules, file transfer rules, and program record definitions must match the expected long records.

Related Mainframe Forum guides

For the surrounding JCL basics, read JCL Tutorial: JOB, EXEC and DD Statements, JCL DD Statement, and JCL Data Set Protection. If the output is kept as generations, also review Generation Data Group in JCL.

External references

IBM documents the main record formats, including fixed, variable, blocked, undefined, and spanned formats, in its z/OS record-format material. See IBM: Data set record formats and IBM: Record formats for the formal wording.

FAQ

What does RECFM=VBS mean?

RECFM=VBS means variable blocked spanned records. Records can have different lengths, more than one record can be placed in a block, and a single logical record can continue into another block.

Is RECFM=VBS the same as RECFM=VB?

No. VB handles variable blocked records where each logical record fits in a block. VBS handles variable blocked records that may span blocks.

Why is LRECL=X used with spanned records?

For QSAM, LRECL=X indicates that the logical record length can be greater than 32,760 bytes. Use it only when the program and data set design require that behavior.

Should I use DISP=MOD with spanned records?

Avoid it unless your site has a tested standard for that exact case. Creating a new output data set is usually easier to restart, audit, and support.

New In-feed ads