test datase empty
Moderators: Frank Yaeger, DikDude, Moderator Group
-
- Member
- Posts: 3
- Joined: Tue Nov 14, 2006 8:52 pm
test datase empty
Hello i'm a new user, i'm italian and don't speak english very well, so excuse me for error.
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.
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.
- Kalicharan
- Moderator
- Posts: 31
- Joined: Wed Feb 08, 2006 1:51 pm
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
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
- Madhusudana Reddy Mandli
- Member
- Posts: 3
- Joined: Wed Nov 15, 2006 6:35 pm
You can check the same using sort .
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
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(SORTCOPY), --> SORT FIELDS=COPY
// DISP=SHR
Thanks
Leo
- Madhusudana Reddy Mandli
- Member
- Posts: 3
- Joined: Wed Nov 15, 2006 6:35 pm
Thanks
Hi Leo,
Thanks a lot.
It looks like a good solution.
Thanks,
Madhu
Thanks a lot.
It looks like a good solution.
Thanks,
Madhu
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
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:
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/
Code: Select all
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//TOOLIN DD *
COUNT FROM(IN) EMPTY RC4
/*
http://www.ibm.com/servers/storage/supp ... vs/tricks/
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Member
- Posts: 6
- Joined: Tue Jul 18, 2006 12:36 pm
You can also use IDCAMS for checking this.
This will give a RC = 12 if the file is empty.
You can also use
which will give RC=4 when the file is empty.
Code: Select all
//FILEMPTY EXEC PGM=IDCAMS
//FILEB DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
REPRO IDS(input file) OFILE(FILEB) COUNT(1)
/*
You can also use
Code: Select all
PRINT IDS(input file) COUNT(1)
Thanks
justaprogrammer
justaprogrammer
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page