test datase empty

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

Post Reply
nick.mamone
Member
Posts: 3
Joined: Tue Nov 14, 2006 8:52 pm

test datase empty

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. :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:

User avatar
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

nick.mamone
Member
Posts: 3
Joined: Tue Nov 14, 2006 8:52 pm

Post by nick.mamone » Wed Nov 15, 2006 5:48 pm

thanks!!!!! :D :D :D :D :D

User avatar
Madhusudana Reddy Mandli
Member
Posts: 3
Joined: Wed Nov 15, 2006 6:35 pm

Post by Madhusudana Reddy Mandli » Wed Nov 15, 2006 7:35 pm

Kali,

Can you give me how to do this using the FILEAID

Thanks in Advance

User avatar
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&#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

User avatar
Madhusudana Reddy Mandli
Member
Posts: 3
Joined: Wed Nov 15, 2006 6:35 pm

Thanks

Post by Madhusudana Reddy Mandli » Fri Nov 17, 2006 4:39 pm

Hi Leo,

Thanks a lot.

It looks like a good solution.


Thanks,
Madhu

User avatar
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&#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/
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

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&#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.
Thanks
justaprogrammer

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 1:38 am

<< Content deleted By Admin >>

Post Reply

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



Other References
Mainframe Tools and others