Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how to find if file is empty or not.

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Tue May 17, 2016 4:39 pm    Post subject: how to find if file is empty or not.
Reply with quote

Hi,

I have searched in this forum and could not find the relevant answer for my question.

I do have a file. If the file has only one record it has to give me a return code of 0 else if it has more records then a return code of greater than 0.

I use the below code, but it always returns me 0 for how many ever records I have.

Code:
//T040D5ZX JOB (P904030,T040,99,99),'EMPTY-TEST1',           
//  NOTIFY=&SYSUID,MSGCLASS=Q,TIME=(02,00),REGION=0M         
//STEP01   EXEC PGM=IDCAMS                                   
//SYSPRINT DD SYSOUT=*                                       
//DD01     DD DSN=T040D5Z.INPUT.CSV,DISP=SHR                 
//SYSIN    DD *                                             
  PRINT INFILE(DD01) COUNT(1)                               
/*                                                           


Please advice.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue May 17, 2016 5:11 pm    Post subject: Reply to: how to find if file is empty or not.
Reply with quote

Quote:
I do have a file. If the file has only one record it has to give me a return code of 0 else if it has more records then a return code of greater than 0.


use a bit of logic, please
averybody can tell about the past, nobody about the future
the same stands for IDCAMS
if You tell it to print 10 record it will tell back if there are less
it will stop at the 10th record ignoring what comes after

but You can easily do it Yourself using Your neurons and a bit of imagination

print ..... count(1)
AND
print ..... count(2)

and set LASTCC and MAXCC accordingly
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue May 17, 2016 7:30 pm    Post subject: Reply to: how to find if file is empty or not.
Reply with quote

some more hints ...

test for success of
print ..... count(1)
the dataset is not empty

AND
test for failure of
print ..... count(2)
the dataset will contain just one record
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Tue May 17, 2016 8:05 pm    Post subject:
Reply with quote

or, if you have SYNCSORT:
Code:
//SORT1    EXEC PGM=SYNCTOOL                                   
//IN1      DD DISP=SHR,DSN=some.data.set name
//TOOLMSG  DD SYSOUT=*                                       
//SSMSG    DD SYSOUT=*                                       
//TOOLIN   DD *                                               
 COUNT FROM(IN1) RC4 NOTEQUAL(1)
/*

If the file is empty or if there is more than 1 record, result will be:
Code:
            COUNT FROM(IN) RC4 NOTEQUAL(1)                 
SYT020I  SYNCSORT CALLED WITH IDENTIFIER "0001"         
SYT075I  CONDITION FOR RECORD COUNT SATISFIED - RC=4 SET
SYT030I  OPERATION COMPLETED WITH RETURN CODE 4         

If there is exactly 1 record:
Code:
            COUNT FROM(IN) RC4 NOTEQUAL(1)                     
SYT020I  SYNCSORT CALLED WITH IDENTIFIER "0001"             
SYT056I  CONDITION FOR RECORD COUNT NOT SATISFIED - RC=0 SET
SYT030I  OPERATION COMPLETED WITH RETURN CODE 0             
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Wed May 18, 2016 11:11 am    Post subject: Reply to: how to find if file is empty or not.
Reply with quote

There's an implication that one record, no more, nor less, is what OP wants to know. If that is so, then NOTEQUAL(1) is what is required with ICETOOL.

The undocumented product (the entire product, not just this operand of a command) SyncTOOL does have NOTEQUAL for COUNT.
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Thu May 19, 2016 5:46 pm    Post subject:
Reply with quote

Hi,

I got it as I needed using ICETOOL. Thanks a lot for your kind help.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us