Delete content of sequential dataset on mainframe.

Delete content of sequential dataset on mainframe

While working with mainframes there will be times when you’d like to delete all the records from a file but want to keep the data set intact. Mostly you’ll see such a situation when you are testing some condition; I doubt you’d ever do it in production but hey! if you do it – well, you are in a situation.

There are many ways to delete content of sequential data set on mainframe and we’ll discuss couple of them here. If you know more, please share them and I’ll update original post with the credits to original poster. Or I’ll add in more as and when I find them.

We can delete content of a sequential data set on mainframe using –

  1. IDCAMS
  2. SORT
  3. COBOL
  1. IDCAMS:  The following JCL will delete content of sequential dataset on mainframe without deleting it using the IDCAMS utility:
//STEP100  EXEC PGM=IDCAMS                                
//DDDMMY   DD DUMMY                                      
//DDOUT    DD DSN=...input file 
//            DISP=SHR                                    
//SYSIN    DD *                                          
  REPRO IFILE(DDDMMY) OFILE(DDOUT)                        
//SYSPRINT DD SYSOUT=*                                    
//SYSOUT   DD SYSOUT=*                                    
//* 

In above JCL, STEP100 is the step which executes the IDCAMS program.

2. SORT: The following JCL will Delete content of sequential dataset on mainframe without deleting it using the SORT:

//EMPTY EXEC PGM=SORT 
//SORTIN DD DISP=SHR,DSN=<dataset> 
//SORTOUT DD DISP=SHR,DSN=<dataset> 
//SYSOUT DD SYSOUT=* 
//SYSIN DD * 
OPTION COPY 
OMIT COND=ALL 
/*

3. COBOL : read the file using COBOL & don’t write anything into it, give your output file DSN with DISP=OLD.