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
| Utility | Use it to |
|---|---|
| IEBGENER | Copy a sequential dataset, optionally reformatting records |
| IEBCOPY | Copy or compress partitioned datasets and their members |
| IDCAMS | Everything VSAM and catalog: define, repro, listcat, delete |
| DFSORT / SORT | Sort, merge, filter, summarise and reformat — far more than sorting |
| IEFBR14 | Do nothing, successfully — used to create or delete datasets via DISP alone |
IEBGENER: the simple copy
//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.
//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
//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
INCLUDE or OMIT in DFSORT does it with three lines and no compile, no load library and no code review.
Many sites have a faster replacement aliased over it. Ask which utility your site prefers for bulk copies.
Without a SYSIN the step fails, even when no reformatting is wanted.
The opposite: the DD statements are the whole point. A wrong DISP there deletes a real dataset.
What you will see at work
- DFSORT control cards appear inline in JCL constantly. Being able to read INCLUDE, OMIT, OUTREC and SUM makes most production JCL legible.
- Sites often have a standard 'scratch and allocate' member you copy rather than writing IEFBR14 steps by hand.
- IDCAMS REPRO is the standard way to load or unload a VSAM file — see the VSAM topic.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.