Page 1 of 1

test datase empty

Posted: Wed Nov 15, 2006 4:08 pm
by nick.mamone
Hello i'm a new user, i'm italian and don't speak english very well, so excuse me for error. :oops:

I must test if a dataset is empty and in this instace setting the return code greater zero.
Is possible do this with a proc ibm and without a specific program?

Thanks, and excuse me for english.

:wink:

Posted: Wed Nov 15, 2006 5:46 pm
by Kalicharan
Hi,

You can get this using ICETOOL or FILEAID or IDCAMS....

Using IDCAMS here is the solution

//STEP01 EXEC PGM=IDCAMS
//IN DD DSN=DATASET <--- Dataset to be checked
//SYSPRINT DD SYSOUT=*
//SYSIN DD DATA
PRINT INFILE(IN) COUNT(1)
/*

This will give RC=0 if file has at least 1 record, otherwise RC=4.


Thanks
Kalicharan

Posted: Wed Nov 15, 2006 5:48 pm
by nick.mamone
thanks!!!!! :D :D :D :D :D

Posted: Wed Nov 15, 2006 7:35 pm
by Madhusudana Reddy Mandli
Kali,

Can you give me how to do this using the FILEAID

Thanks in Advance

Posted: Fri Nov 17, 2006 4:27 pm
by Leo
You can check the same using sort .

Code: Select all

//STEP100 EXEC PGM=SORT,PARM='NULLOUT=RC4' 
//SYSOUT   DD SYSOUT=* 
//SORTIN   DD DSN= Input file name goes here,  
//            DISP=SHR 
//SORTOUT  DD DUMMY 
//SYSIN    DD DSN=&CTLCARD&#40;SORTCOPY&#41;, --> SORT FIELDS=COPY 
//            DISP=SHR 
This will give a return code of 4 if the file is empty , you can check for the return code of this step down the line in the job . hope this was helpful

Thanks
Leo

Thanks

Posted: Fri Nov 17, 2006 4:39 pm
by Madhusudana Reddy Mandli
Hi Leo,

Thanks a lot.

It looks like a good solution.


Thanks,
Madhu

Posted: Fri Nov 17, 2006 9:50 pm
by Frank Yaeger
Note that Leo's job will only work for z/OS DFSORT V1R5, not for DFSORT R14. Here's a DFSORT/ICETOOL job that will work for both:

Code: Select all

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file
//TOOLIN DD *
COUNT FROM&#40;IN&#41; EMPTY RC4
/*
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/supp ... vs/tricks/

Posted: Wed Nov 22, 2006 6:42 pm
by justaprogrammer
You can also use IDCAMS for checking this.

Code: Select all

//FILEMPTY   EXEC   PGM=IDCAMS
//FILEB         DD      DUMMY
//SYSPRINT   DD     SYSOUT=*
//SYSIN         DD    *
    REPRO IDS&#40;input file&#41; OFILE&#40;FILEB&#41; COUNT&#40;1&#41;
/*
This will give a RC = 12 if the file is empty.

You can also use

Code: Select all

PRINT IDS&#40;input file&#41; COUNT&#40;1&#41;
which will give RC=4 when the file is empty.

Topic deleted by Admin

Posted: Mon Feb 01, 2016 1:38 am
by academyindia4
<< Content deleted By Admin >>