To check if a sequential File is empty is a usual step added in a job on practical scenario. The  general use cases for doing the same are : 

  1. To skip the further processing of the job if the file is empty
  2. To check if the file has arrived from an external source and if it contains data
  3. To check if the allocated file does not contain any junk data

This can be achieved with different JCL utilities such as ICETOOL, FILEAID, IDCAMS etc

A.Using ICETOOL

  1. Using EMPTY operand

EMPTY operand with COUNT can be used to find if the file is empty. By default, return 12 will be returned if the file is empty. 

//EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//INDD    DD DSN=<input file>,
//      DISP=SHR
//TOOLIN DD *
  COUNT FROM(INDD) EMPTY
/*

Since return code above 4 is not considered ideal in a system and it may even fail in a scheduler unless specified, hence it is advised to override the return using RC command

//EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//INDD    DD DSN=<input file>,
//      DISP=SHR
//TOOLIN DD *
  COUNT FROM(INDD) EMPTY RC4
/*
  1. Using HIGHER operand

HIGHER operand with COUNT can also be used to find if the file is empty. By default, return 12 will be returned if the file is empty. This return code can be overridden as above.

//EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*

//DFSMSG  DD SYSOUT=*
//INDD    DD DSN=<input file>,
//      DISP=SHR
//TOOLIN DD *
  COUNT FROM(INDD) HIGHER(0) RC4
/*

The above two methods can be used along with MODE STOP to stop further processing of control cards in ICETOOL if the file is empty or continue the processing if records are present as shown below. Control Card 1 in the below step will not be processed if the file is empty and the return code will be RC4.

//EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//INDD    DD DSN=<input file>,
//      DISP=SHR
//OUTDD   DD DSN=<output file>,
//      DISP=SHR
//TOOLIN DD *
  MODE STOP
  COUNT FROM(INDD) HIGHER(0) RC4
  SORT FROM(INDD)TO(OUT) USING(CTL1)
/*
//CTL1CNTL DD *
  SORT FIELDS=(1,10,BI,A)
/*

B.Using IDCAMS

In IDCAMS, the PRINT operand and REPRO operand can be used to check the file. 

If the file is empty, this step will give RC 04, else the return code will be 00.

//EXEC PGM=IDCAMS
//INDD     DD DSN=<input file>,
//        DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  PRINT INFILE(INDD) CHARACTER COUNT(1)
/*
//EXEC PGM=IDCAMS
//INDD     DD DSN=<input file>,
//        DISP=SHR
//OUTDD    DD DSN=<input file>,
/        DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  REPRO INFILE(INDD)OUTFILE(OUTDD)CHARACTER COUNT(1)
/*