Check for empty file

There may be scenarios where you wish to check if a file is empty or not one example for such situation is you are sending a report to client if there are transactions processed and if the file is empty then you do not wish to send the  The following JCL using IDCAMS can be used to check if a file is empty or not Returns CC of 0 – if file has records Returns CC of 4 if the file is empty. 

//STEP001  EXEC PGM=IDCAMS //INPUT    DD DSN=FILE.TO.CHECK,  PRINT INFILE(INPUT) CHARACTER COUNT(1)