Page 1 of 1

Handle VSAM empty file

PostPosted: Fri Jun 05, 2009 10:54 am
by satishmf
My Production job is such that, on one of the steps it has to
copy a VSAM dataset to flat file, and then process that flat
file in the subsequent steps. Sometimes the input VSAM may be
empty. When its empty, my job abends. How can I prevent the job
from abending when the VSAM is empty ?

Re: Handle VSAM empty file

PostPosted: Fri Jun 05, 2009 11:59 am
by expat
Use SORT to copy perform the copy, using the option to issue a return code of 4 or 16 if the output has zero records, and execute the rest of the job conditionally from that point on.
//DFSORT   EXEC PGM=SORT,PARM='NULLOUT=RC4'

Re: Handle VSAM empty file

PostPosted: Fri Jun 05, 2009 8:46 pm
by Frank Yaeger
You can use DFSORT to copy a VSAM data set to a sequential file without terminating when the file is empty. Just ensure that the VSAMEMT option is in effect (this is DFSORT's shipped default). You can ensure the VSAMEMT option is in effect with:

//DFSPARM DD *
   OPTION VSAMEMT
/*


If you want a RC=4 or RC=16 when the file is empty, you can use the NULLOUT=RC4 or NULLOUT=RC16. If you want a RC=0 when the file is empty, you can use NULLOUT=RC0 (DFSORT's shipped default).