NEW and CATLG
Part of the Batch Jobs with JCL section of Coddy's COBOL Programming journey. Lesson 6 of 19.
DISP has three parts: the status, what to do when the step ends normally, and what to do when it ABENDs (ends abnormally):
//BIGOUT DD DSN=CODDY.CUST.BIG,DISP=(NEW,CATLG,DELETE)CATLG keeps the new data set and records its name in the catalog, so later steps and jobs find it by name. KEEP keeps it, and DELETE deletes it. Here a normal end catalogs it and an ABEND deletes it.
Left out, the normal part is DELETE for a new data set and KEEP for one that existed, and the ABEND part copies the normal one. So DISP=NEW alone deletes the data set when its step ends, and the next step does not find it.
A real job also says how much disk to give a new data set, and a long statement continues after a comma on a line starting // and a blank:
//BIGOUT DD DSN=CODDY.CUST.BIG,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,1))This course's system accepts SPACE, UNIT and DCB and needs none of them.
A NEW data set whose name is already cataloged is a JCL error:
IGD17101I DATA SET CODDY.CUST.BIG NOT DEFINED BECAUSE DUPLICATE NAME EXISTS IN CATALOGChallenge
EasyPICK copies the large balances to the DD name BIGOUT, and LIST reads them from CODDY.CUST.BIG. Add the BIGOUT DD that creates CODDY.CUST.BIG, catalogs it when the step ends normally and deletes it on an ABEND.
Try it yourself
//BIGCUST JOB (ACCT),'CODDY',CLASS=A,MSGCLASS=X
//PICK EXEC PGM=EXTRACT
//CUSTIN DD DSN=CODDY.CUST.MASTER,DISP=SHR
//* Add the BIGOUT DD here
//SYSOUT DD SYSOUT=*
//LIST EXEC PGM=LISTCUST
//CUSTIN DD DSN=CODDY.CUST.BIG,DISP=SHR
//SYSOUT DD SYSOUT=*
All lessons in Batch Jobs with JCL
Practice on your own: Online COBOL compiler