Checking the Data existence in a file.

JES2/3, JCL, utilities.
Post Reply
Prashant Ranade
New Member
Posts: 2
Joined: Tue Aug 19, 2014 9:37 am

Checking the Data existence in a file.

Post by Prashant Ranade »

For a file having just one row of data if ever, is of FB andLRECL 80. Along with that if the file is empty, I need to check if the file has some data. But the problem is that spaces are not considered as data.

I used IDCAMS REPRO with COUNT(1) but it does not flag the file as EMPTY as there are spaces.

Can you please help me?
User avatar
Akatsukami
Global Moderator
Global Moderator
Posts: 122
Joined: Tue Oct 20, 2015 3:20 am
Location: Bloomington, IL
Contact:

Re: Checking the Data existence in a file.

Post by Akatsukami »

Why not just do a read on it and, if you do not get an EOF condition, check if the record has a non-space in it?
"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli
vikriih
New Member
Posts: 8
Joined: Sat Oct 24, 2015 3:31 pm

Re: Checking the Data existence in a file.

Post by vikriih »

use the following code

Code: Select all

//ST010   EXEC PGM=IDCAMS                                
 //SYSOUT   DD SYSOUT=*                                  
 //SYSPRINT DD SYSOUT=*                                  
 //FILEIN   DD DSN=TSO.REC.IN,DISP=SHR      
 //SYSIN    DD *                                          
   PRINT INFILE(FILEIN) -                                
       CHARACTER COUNT(1)  
It should return a return code of 4 if the dataset is empty
Last edited by Anuj Dhawan on Mon Oct 26, 2015 4:38 pm, edited 1 time in total.
Reason: Coded
enrico-sorichetti
Global Moderator
Global Moderator
Posts: 825
Joined: Wed Sep 11, 2013 3:57 pm

Re: Checking the Data existence in a file.

Post by enrico-sorichetti »

a plain utility will not do...

NON empty in this context means significant data
which means at least ONE NON blank record

for idcams a record containing just blanks is ... A RECORD
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort 8-)
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Checking the Data existence in a file.

Post by nicc »

Cannot do it with JCL - JCL does not look at data. Your sort product may be able to do it - include where String Search finds data in 1 to 80 > x'40' and stop after 1 record.
Regards
Nic
User avatar
Akatsukami
Global Moderator
Global Moderator
Posts: 122
Joined: Tue Oct 20, 2015 3:20 am
Location: Bloomington, IL
Contact:

Re: Checking the Data existence in a file.

Post by Akatsukami »

Prashant-kun, you'll likely also want to use the NULLOUT opton to have DFSORT or Syncsort give a non-zero return code if the data set is empty.
"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Checking the Data existence in a file.

Post by zprogrammer »

Prashanth,

Do you expect multiple records with SPACE?
zprogrammer
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “JCL - Job Control Language.”