How to test a empty file through JCL

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
kapil agarwal
Member
Posts: 10
Joined: Thu Mar 05, 2009 5:50 pm
Location: Bangalore

How to test a empty file through JCL

Post by kapil agarwal » Sat Mar 21, 2009 11:13 pm

Hi,

How to check a file through JCl that its empty or not?
Kapil K Agarwal
Bangalore

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Post by Krishna » Sun Mar 22, 2009 11:32 am

There are multiple ways you can achieve this...

Using ICE TOOL...

// EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INFILE DD DSN=XXX.YYY.ZZZ,DISP=SHR
//TOOLIN DD *
COUNT FROM(INFILE) EMPTY
/*

RC=12, tells us.. given file is empty.



Using IDCAMS.

//CHECKING EXEC PGM=IDCAMS
//INFILE DD DSN=XXX.YYY.ZZZ,DISP=SHR
//SYSIN DD *
PRINT INFILE(INFILE) COUNT(1)
IF LASTCC NE 0 THEN SET LASTCC = 12
/*


RC=12, tells us.... given file is empty.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Sun Mar 22, 2009 11:20 pm

Kapil,

See the "Set RC=12 or RC=4 if file is empty, has more than n records, etc" Smart DFSORT Trick at:

http://www.ibm.com/systems/support/stor ... vs/tricks/
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others