MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to check for an empty file?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Sun Dec 01, 2002 11:13 pm    Post subject: How to check for an empty file? Reply with quote

Code:

//*-------------------------------------------------------------------*
//*  SETS RC=0000 IF DATASET HAS RECORDS                              *
//*  SETS RC=0004 IF DATASET IS EMPTY                                 *
//*-------------------------------------------------------------------*
//STEP0100 EXEC PGM=IDCAMS 
//SYSPRINT DD SYSOUT=*
//MYFILE   DD DSN=<datasetname>,
//            DISP=SHR
//SYSIN    DD *
  PRINT INFILE(MYFILE) CHARACTER COUNT(1)
/*
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Dec 04, 2002 11:43 am    Post subject: Reply with quote

You can also do this with DFSORT's ICETOOL:

Code:

//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...
//TOOLIN DD *
* SET RC=12 IF THE 'IN' DATA SET IS EMPTY, OR
* SET RC=0 IF THE 'IN' DATA SET IS NOT EMPTY
   COUNT FROM(IN) EMPTY
/*
// IF STEP1.RC = 0 THEN
//*** STEP2 WILL RUN IF 'IN' IS NOT EMPTY
//*** STEP2 WILL NOT RUN IF 'IN' IS EMPTY
//STEP2 EXEC ...
...
// ENDIF


For more information, 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/servers/storage/support/software/sort/mvs/tricks/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group