Mainframe Path Start learning free
Core8 min readLesson 4 of 4

The utilities that move data around

You rarely write a program to copy, compare or reformat a file. There is a utility for it, and knowing five of them covers most day-to-day work.

The five worth knowing

UtilityUse it to
IEBGENERCopy a sequential dataset, optionally reformatting records
IEBCOPYCopy or compress partitioned datasets and their members
IDCAMSEverything VSAM and catalog: define, repro, listcat, delete
DFSORT / SORTSort, merge, filter, summarise and reformat — far more than sorting
IEFBR14Do nothing, successfully — used to create or delete datasets via DISP alone

IEBGENER: the simple copy

Copy one sequential file to another
//COPYSTEP EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1   DD DSN=PROD.PAY.TRANS,DISP=SHR          <- input
//SYSUT2   DD DSN=TEST.PAY.TRANS,DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(10,5),RLSE)
//SYSIN    DD DUMMY                                <- no reformatting

IEFBR14: the useful do-nothing

IEFBR14 is a program that immediately returns. Its entire purpose is to let the *DD statements* do the work: allocation and disposition happen even though nothing runs. This is the standard way to create an empty dataset or delete one from JCL.

Delete two datasets and create one
//SETUP    EXEC PGM=IEFBR14
//DEL1     DD DSN=TEST.PAY.WORK1,DISP=(MOD,DELETE,DELETE),
//            SPACE=(TRK,(1,1)),UNIT=SYSDA
//DEL2     DD DSN=TEST.PAY.WORK2,DISP=(MOD,DELETE,DELETE),
//            SPACE=(TRK,(1,1)),UNIT=SYSDA
//NEW1     DD DSN=TEST.PAY.OUT,DISP=(NEW,CATLG,DELETE),
//            SPACE=(CYL,(5,5),RLSE),
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)

DFSORT: much more than sorting

Sort, filter, and cut fields in one pass
//SORTSTEP EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=PROD.PAY.TRANS,DISP=SHR
//SORTOUT  DD DSN=&&SORTED,DISP=(NEW,PASS),SPACE=(CYL,(20,5))
//SYSIN    DD *
  SORT    FIELDS=(1,8,CH,A,20,4,PD,D)   <- key 1 asc, key 2 desc
  INCLUDE COND=(30,1,CH,EQ,C'Y')       <- keep only flagged rows
  OUTREC  FIELDS=(1,8,20,4,50,25)        <- keep only these fields
/*

DFSORT can also count records, remove duplicates, join files, split one file into many, and generate reports. At most sites it does more data manipulation than any program, because it is faster than writing one and needs no compile.

Common mistakes

Writing a COBOL program to filter a file

INCLUDE or OMIT in DFSORT does it with three lines and no compile, no load library and no code review.

Using IEBGENER for very large copies

Many sites have a faster replacement aliased over it. Ask which utility your site prefers for bulk copies.

Forgetting SYSIN DD DUMMY on IEBGENER

Without a SYSIN the step fails, even when no reformatting is wanted.

Assuming IEFBR14 ignores DD statements

The opposite: the DD statements are the whole point. A wrong DISP there deletes a real dataset.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← Catalogs: how a name becomes a locationBack to Datasets and catalog concepts