In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3
Moderators: Frank Yaeger , DikDude , Moderator Group
nick.mamone
Member
Posts: 3 Joined: Tue Nov 14, 2006 8:52 pm
Post
by nick.mamone » Wed Nov 15, 2006 4:08 pm
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.
Kalicharan
Moderator
Posts: 31 Joined: Wed Feb 08, 2006 1:51 pm
Post
by Kalicharan » Wed Nov 15, 2006 5:46 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
Leo
Member
Posts: 13 Joined: Tue Nov 14, 2006 12:02 pm
Location: HYBD
Post
by Leo » Fri Nov 17, 2006 4:27 pm
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(SORTCOPY), --> 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
Frank Yaeger
Moderator
Posts: 812 Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:
Post
by Frank Yaeger » Fri Nov 17, 2006 9:50 pm
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(IN) 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/
justaprogrammer
Member
Posts: 6 Joined: Tue Jul 18, 2006 12:36 pm
Post
by justaprogrammer » Wed Nov 22, 2006 6:42 pm
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(input file) OFILE(FILEB) COUNT(1)
/*
This will give a RC = 12 if the file is empty.
You can also use
Code: Select all
PRINT IDS(input file) COUNT(1)
which will give RC=4 when the file is empty.
Thanks
justaprogrammer
academyindia4
Post
by academyindia4 » Mon Feb 01, 2016 1:38 am
<< Content deleted By Admin >>
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.
Mainframe Interview questions
Mainframe Tools and others