In your JCL use DISP=(NEW,CATLG,DELETE).
1) You're creating a NEW data set
2) If the job step completes successfully the data set should be cataloged
3) If the job step ABENDs the data set should be deleted.
Cataloging a data set means the name of the data set, allocation data (like VOLUME, LRECL, RECFM etc.) are added to one of the system catalogs.
When you need the data set again, you don't have to know any of these parameters, just use DSN=data.set.name,DISP=SHR and the system will know on which volume this data set resides.
If you update the file after you create it, use disp=old instead of disp=shr. This prevents anyone from using your ds when you update. Allowing someone else access at that time can cause problems for you, them or both.
As I recall the DCB params (LRECL, RECFM, etc.) are carried in the DSCB on which the file was allocated, not the Catalog... unless they changed it recently. Minor point, but it s/b noted.
Joined: 07 Nov 2005 Posts: 1105 Location: The Netherlands at Hole 19
I'd also like to ad to the comments. Normally a job will run more than once using the same JCL. You should prevent failure when your job tries to construct/catalog the dataset (you can't create a dataset with disp=new when it already exists unless it's not catalogued and resides on different volumes). We use to insert a small step at the beginning of the job which takes care of that.
//DELETE EXEC PGM=IEFBR14 (just an exit without functionality)
//SYSOUT DD SYSOUT=*
//DD1 DD DSN=dataset-to-delete,DISP=(MOD,DELETE,DELETE),
the MOD is meant to prevent a condition code 4 in case the dataset didn't exist.