Checking the Data existence in a file.
-
- New Member
- Posts: 2
- Joined: Tue Aug 19, 2014 9:37 am
Checking the Data existence in a file.
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?
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?
- Akatsukami
- Global Moderator
- Posts: 122
- Joined: Tue Oct 20, 2015 3:20 am
- Location: Bloomington, IL
- Contact:
Re: Checking the Data existence in a file.
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
Re: Checking the Data existence in a file.
use the following code
It should return a return code of 4 if the dataset is empty
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)
Last edited by Anuj Dhawan on Mon Oct 26, 2015 4:38 pm, edited 1 time in total.
Reason: Coded
Reason: Coded
- enrico-sorichetti
- Global Moderator
- Posts: 843
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Checking the Data existence in a file.
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
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
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

Re: Checking the Data existence in a file.
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
Nic
- Akatsukami
- Global Moderator
- Posts: 122
- Joined: Tue Oct 20, 2015 3:20 am
- Location: Bloomington, IL
- Contact:
Re: Checking the Data existence in a file.
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
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Checking the Data existence in a file.
Prashanth,
Do you expect multiple records with SPACE?
Do you expect multiple records with SPACE?
zprogrammer
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