Verify whether a dataset is empty.

How do you verify whether a dataset is empty using a JCL?

Questions by mohammadanis.jamadar   answers by mohammadanis.jamadar

Showing Answers 1 - 15 of 15 Answers

Ashish Jain

  • Jun 4th, 2012
 

JCL to find if a dataset is empty
In your batch job, if there is a need to check for empty dataset, you can do it using IDCAMS.

Code
  1. //*-------------------------------------------------------------------*/

  2. //* This JCL is to find if a file is empty or not. If there are no    */

  3. //* records, the return-code will be 4.                               */

  4. //*-------------------------------------------------------------------*/

  5. //STEP01   EXEC PGM=IDCAMS

  6. //SYSPRINT  DD SYSOUT=*

  7. //IN1       DD DISP=SHR,DSN=your.dataset.name

  8. //SYSIN     DD *

  9.   PRINT INFILE(IN1) COUNT(001)

  10. /*

  11.  

  12.  

  13. If you have ICETOOL at your site, you can use that as well.

  14.  

  15. //*-------------------------------------------------------------------*/

  16. //* This JCL is to find if a file is empty or not using ICETOOL.      */

  17. //* If there are no records, the return-code will be 12               */

  18. //*-------------------------------------------------------------------*/

  19. //STEP01  EXEC PGM=ICETOOL

  20. //TOOLMSG  DD SYSOUT=*

  21. //DFSMSG   DD SYSOUT=*

  22. //IN       DD DISP=SHR,DSN=your.dataset.name

  23. //TOOLIN   DD *

  24. COUNT FROM(IN) EMPTY

  25. /*


Tarun

  • Jun 6th, 2012
 

Use IDCAMS to print the records present in dataset.
If present, the job will end with MAXCC 0000 otherwise MAXCC 0004 i.e. empty file.

Thanks,
Tarun

  Was this answer useful?  Yes

Rishu

  • Jul 28th, 2014
 

There are three ways to check if file is empty or not.
1:- Through IDCAMS, it is already explained above.
2:- Through ICETOOL, it is also explained above.
3:- Through SORT::
OPTION COPY
OUTFIL NULLOFL = RC12
When file is null then only return code is set to null.

  Was this answer useful?  Yes

Nagaraju

  • May 12th, 2017
 

using IDCAMS along with PRINT parameter.
It returns 0 data available in file.
It returns 4 data not available in file

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions