Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Tue Nov 29, 2005 12:04 pm Post subject: Empty File Checking |
|
|
Question: How to check if an dataset is empty ?
Solution: There are many ways to do this. Apart from using programming languages like COBOL, we can utilize tools like Sort, Eazytrieve, IDCAMS etc...to do the job.
Here are few samples.
1. Using IDCAMS
Code: |
//*-------------------------------------------------------------------*
//* SETS RC=0000 IF DATASET HAS RECORDS *
//* SETS RC=0004 IF DATASET IS EMPTY *
//*-------------------------------------------------------------------*
//STEP0100 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//MYFILE DD DSN=<datasetname>,
// DISP=SHR
//SYSIN DD *
PRINT INFILE(MYFILE) CHARACTER COUNT(1)
/*
|
2. Using SORT
If you are using DFSORT - You will need z/OS DFSORT V1R5.
If you are using Syncsort - You will need syncsort 3.7 with TPF2A or higher to work.
Note: NULLOUT=RC16 can be used to give RC=16 instead of RC=4.
Code: |
//*********************************************************************
//* SETS RC=0000 IF DATASET HAS RECORDS *
//* SETS RC=0004 IF DATASET IS EMPTY *
//*********************************************************************
//STEP0100 EXEC PGM=SORT,PARM='NULLOUT=RC4'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR FILE IN QUESTION,
// DISP=SHR
//SORTOUT DD DUMMY
//SYSIN DD *
SORT FIELDS=COPY
/*
|
3. Using SORT - With DFSORT's ICETOOL Change PGM to SYNCTOOL if you are using Syncsort.
Code: |
//*******************************************************************
//* SETS RC=0000 IF DATASET HAS RECORDS *
//* SETS RC=0012 IF DATASET IS EMPTY *
//* With DFSORT's ICETOOL, you can use the RC4 keyword *
//* to get RC=0004 instead of RC=0012. *
//*******************************************************************
//EMPTY EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//FILEIN DD DSN=your.dataset,DISP=SHR
//TOOLIN DD *
COUNT FROM(FILEIN) EMPTY
/*
|
4. Using FILEAID
Code: |
//********************************************************************
//* SETS RC=0000 IF DATASET HAS RECORDS *
//* SETS RC=0008 IF DATASET IS EMPTY *
//********************************************************************
//STEP0100 EXEC PGM=FILEAID,REGION=0M
//SYSPRINT DD SYSOUT=*
//DD01 DD DSN=YOUR FILE IN QUESTION,
// DISP=SHR
//DD01O DD SYSOUT=*
//SYSIN DD *
$$DD01 COPY
//*
|
5. Using IEBPTPCH
Code: |
//*********************************************************************
//* SETS RC=0000 IF DATASET HAS RECORDS *
//* SETS RC=0004 IF DATASET IS EMPTY *
//*********************************************************************
//STEP0100 EXEC PGM=IEBPTPCH
//SYSUT1 DD DSN=YOUR FILE IN QUESTION,
// DISP=SHR
//SYSUT2 DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT
//*
|
6. Using Super-C (ISRSUPC)
Code: |
//*********************************************************************
//* SETS RC=0001 IF DATASET HAS RECORDS *
//* SETS RC=0028 IF DATASET IS EMPTY *
//*********************************************************************
//STEP0100 EXEC PGM=ISRSUPC
//SYSPRINT DD SYSOUT=*
//OUTDD DD SYSOUT=*
//OLDDD DD DUMMY
//NEWDD DD DSN=YOUR FILE IN QUESTION,
// DISP=SHR
//SYSIN DD DUMMY
|
7. Using Eazytrieve
Code: |
//*********************************************************************
//* SETS RC=0000 IF DATASET HAS RECORDS *
//* SETS RC=0012 IF DATASET IS EMPTY *
//*********************************************************************
//STEP0100 EXEC PGM=EZTPA00
//STEPLIB DD DSN=EASYTREV.LOADLIB,
// DISP=SHR
//SYSPRINT DD SYSOUT=*
//FILEIN DD DSN=YOUR FILE IN QUESTION,
// DISP=SHR
//SYSIN DD *
FILE FILEIN
JOB INPUT NULL
GET FILEIN
IF EOF FILEIN
RETURN-CODE = 12
ELSE
RETURN-CODE = 00
END-IF
STOP
/*
|
Links on similar topics
http://www.mvsforums.com/helpboards/viewtopic.php?t=3412&highlight=empty+file+check
http://www.mvsforums.com/helpboards/viewtopic.php?t=2215&highlight=empty+file+check
http://www.mvsforums.com/helpboards/viewtopic.php?t=1285&highlight=empty+file+check
http://www.mvsforums.com/helpboards/viewtopic.php?t=27&highlight=empty+file+check
Thanks,
Phantom |
|