Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

which is the JCL utility that can tell me if a file is empty or not 1

Status
Not open for further replies.

deveshjogal

Programmer
Dec 30, 2002
61
hi all

On OS/390 (MVS) is there any JCL utility which can tell me if a flat file contains any record or not ?? Can anybody give syntax too ?

Thanks
devesh
 
IEBGENER will work. It copies files and gives statistics indicating how many records it copied. You can DUMMY out the output file since you don't care about copying.

//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD DSN=input file
//SYSUT2 DD DUMMY,DCB=(RECFM=FB,LRECL=xx,BLKSIZE=xx)
//SYSIN DD DUMMY
//SYSOUT DD SYSOUT=*

SYSUT1 is the input file. SYSUT2 is the output file you don't care about. With the utility, you need to provide DCB when you DUMMY the file. SYSOUT is where the statistical report will be printed.
 
Note that you can code

//SYSUT2 DD DUMMY,DCB=input file

to copy the input file DCB to SYSUT2. That way you don't have to check it.
 
We can use IDCAMS utility also for this in the following way.

//Job statement**********
//Step1 exec pgm=IDCAMS
//DD1 DD DSN=....Input file (to be checked) PS/VSAM
//DD2 DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSABEND DD SYSOUT=*
//SYSIN DD *
REPRO -
INFILE(DD1) -
OUTFILE(DD2) SKIP(1) COUNT(0)
//

RC would be 12 , if the input file is empty.


Include a COND parm in the next step, to check whether RC is 12.

-Indhu


 
I should make a correction before someone else catches it. In the JCL for IEBGENER the statistical report goes to the DD SYSPRINT. I was doing this from memory and got my utilities mixed up when writing the JCL.

//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD DSN=input file
//SYSUT2 DD DUMMY,DCB=(RECFM=FB,LRECL=xx,BLKSIZE=xx)
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
 
Thank U.

My requirement is that if the file is not empty then i will be FTPing it. SO I think I will use IDCAM utility and check the return code.

Thanks

devesh
 
Hi All,

If memory serves, and that's becoming more problematic every day :), there are 2 kinds of "empty".

1) There is no data in the file and it hasn't been closed at least once.

2) There is no data and the file has been closed.

For example, a closed PS file has a file or tape mark in it. A VSAM file has a high RBA (I think) in it. Note that most say "initialized" instead of "closed". Is there a difference? Don't know, but the idea is the same.

But the important thing to infer from this is that IDCAMS,
will return a 12 if a type 2 "empty" exists in the file or doesn't exist at all, or return a 4 if a type 1 is in effect.

I'm not sure of what effect Indhu's IDCAMS cntl cards will have on this, I usually use:

PRINT dsname COUNT(1)

I haven't tested this against PDS members.

The important thing to come away with from this is that it's not as straightforward as one might think. So, test thoroughly before you put it into production.

HTH, Jack.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top