MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Empty file
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Tue Oct 07, 2003 4:02 am    Post subject: Empty file Reply with quote

I've 2 steps in a job. In step1 a file is being created and updated and in step2 file is being used for reading.
I want to check if the file is empty after completion of step1 then step2 should not be executed at all. How can this be done ?
Back to top
View user's profile Send private message Send e-mail
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Tue Oct 07, 2003 6:02 am    Post subject: Reply with quote

Add intermediate IDCAMS step like this:
Code:
//REPRO  EXEC PGM=IDCAMS                                 
//SYSPRINT DD SYSOUT=*                                   
//FILEIN   DD DSN=your.dataset,DISP=SHR   
//FILEOUT  DD DSN=your.dataset,DISP=SHR   
//SYSIN    DD *                                         
  REPRO INFILE(FILEIN) OUTFILE(FILEOUT) COUNT(1)         
/*                                                       


If the file is empty, this step will end with RC=4, else it will end with RC=0.

O.
________
[URL=http://www.ford-wiki.com/wiki/Ford_Fairlane_(Australia)]Ford Fairlane (Australia) history[/URL]


Last edited by ofer71 on Sat Feb 05, 2011 11:06 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Tue Oct 07, 2003 7:29 am    Post subject: Reply with quote

One more way

Code:

//EMPTY  EXEC PGM=ICETOOL                                 
//TOOLMSG DD SYSOUT=*                                   
//DFSMSG DD SYSOUT=*                                   
//FILEIN   DD DSN=your.dataset,DISP=SHR   
//TOOLIN    DD *                                         
  COUNT FROM(FILEIN) EMPTY
/*                           


This will come out with an RC of 12, if IN is empty

Hope it helps...

Cheers,
Coolman
________
buy vapir one


Last edited by coolman on Sat Feb 05, 2011 1:31 am; edited 1 time in total
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Tue Oct 07, 2003 7:53 am    Post subject: Reply with quote

The following are various methods of checking for an empty file.

Method1: IDCAMS

Code:

//*********************************************************************
//*  SETS RC=0000 IF DATASET HAS RECORDS                              *
//*  SETS RC=0004 IF DATASET IS EMPTY                                 * //*********************************************************************
//STEP0100 EXEC PGM=IDCAMS                       
//SYSPRINT DD SYSOUT=*                           
//FILE01   DD DSN=YOUR FILE IN QUESTION,
//            DISP=SHR   
//SYSIN    DD  *                                 
   PRINT INFILE(FILE01) CHARACTER COUNT(1)       
//*



Method2: DFSORT/ICETOOL

Code:

//*********************************************************************
//*  SETS RC=0000 IF DATASET HAS RECORDS                              *
//*  SETS RC=0012 IF DATASET IS EMPTY                                 * //*********************************************************************
//STEP0100 EXEC PGM=ICETOOL         
//*                                   
//TOOLMSG  DD SYSOUT=*               
//DFSMSG   DD SYSOUT=*               
//IN       DD DSN=YOUR FILE IN QUESTION,
//            DISP=SHR
//TOOLIN DD *
  COUNT FROM(IN) EMPTY
//*


Method3: Syncsort-You will need syncsort 3.7 with TPF2A or higher to work *

Code:

//*********************************************************************
//*  SETS RC=0000 IF DATASET HAS RECORDS                              *
//*  SETS RC=0004 IF DATASET IS EMPTY                                 *
//*  You will need syncsort 3.7 with TPF2A or higher to work          *
//*********************************************************************
//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                               
/*


MetHod4: File-aid
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                                     
//*

Method5: 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                               
//*                                   


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


Method:7 Easytrieve
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                     
/*



Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Tue Oct 07, 2003 8:10 am    Post subject: Reply with quote

Hats off Kolusu Sir.
________
apple games


Last edited by coolman on Sat Feb 05, 2011 1:31 am; edited 1 time in total
Back to top
View user's profile Send private message
naveen
Beginner


Joined: 03 Dec 2002
Posts: 90
Topics: 31

PostPosted: Tue Oct 07, 2003 9:42 am    Post subject: Reply with quote

Thanks a lot Kolusu.
Multiple solutions . I hope there is no other way left.
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Tue Oct 07, 2003 10:21 am    Post subject: Reply with quote

For more information on the DFSORT/ICETOOL method, 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/support/software/sort/mvs/tricks/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort


Last edited by Frank Yaeger on Mon Sep 11, 2006 6:57 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Wed Oct 08, 2003 8:27 pm    Post subject: Reply with quote

Hi,

I'm sure most of us have encountered these 2 flavors of "empty":

1) An allocated but never closed file is considered empty. This file contains no EOF indicator and cannot be successfully read.

2) A file that contains no data but was successfully closed after open for output or IO, or one that contained data that was subsequently deleted from the file, can be successfully opened for input. Reading these files will result in an EOF condition after the 1st sequential read.

There are times when it is desirable to handle these two conditions differently. I know that IDCAMS issues distinct completion codes for each of these conditions.

Do the other solutions do the same?

Regards, Jack.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Thu Oct 09, 2003 4:22 am    Post subject: Reply with quote

Slade,

Quote:

I know that IDCAMS issues distinct completion codes for each of these conditions.


As far as I remember I don't think IDCAMS issues distinct completion codes for regualar seq datasets.It might for VSAM datasets.( I am not sure as I need to test it and it is too early in the morning here). I remember vaguely about initializing empty vsam datasets.

Let us say I allocate a dataset(3.2) and issue a idcams command to print , then the job ends with return code of 4.

Let us I have another existing dataset and just open and delete all the records in that dataset and issue a idcams command to print , then the job still ends with return code of 4.

can you clarify the scenario of IDCAMS issuing distinct completion codes???

Thanks,

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Thu Oct 09, 2003 11:46 am    Post subject: Reply with quote

Kolusu,

In one scenerio the file is allocated via JCL (e.g. IEFBR14 or as a step DD but it is never opened in the user pgm). I beleive this will produce an RC=8 (maybe 12).

I the other, ISPF is used to create the file via edit and edit is exited before any recs are created or the file is created via JCL and is opened for output or IO in a pgm. As I recall, it doesn't have to be closed by the pgm since system step termination closes all files left open at prm exit. In this case ISPF produces an EOF indicator, so the file is "initialized". In this case an RC=4 is generated by IDCAMS.

If the file contains data recs an RC=0 is returned.

I've stated these actions as facts, but they're only my recollections.


Regards, Jack.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Thu Oct 09, 2003 2:31 pm    Post subject: Reply with quote

Jack,
I think IEFBR14 now sets the EOF MARK for SMS managed datasets.I am not sure about the non sms managed datasets.so IDCAMS in this case will issue a return code of 4 for a dataset allocated using IEFBR14.Idcams would issue a return code of 12 if it is a vsam cluster which is defined but not initialized.IDCAMS issues a return code of 12 when the dataset is not found in the catalog or when the catalog cannot be accessed.

Incase of vsam datasets I think sort products are good to test for a empty vsam cluster using the parm VSAMEMT . This parm determines how an empty VSAM input data set will be processed. If VSAMEMT=YES, an empty VSAM data set will be processed as legitimate data set contain 0 records, and Sort will end with a return code of 0.

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Fri Oct 10, 2003 1:50 pm    Post subject: Reply with quote

Kolusu,

I couldn
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Fri Oct 10, 2003 2:20 pm    Post subject: Reply with quote

Jack,

I will try to find the link for SMS datasets setting the EOF mark.But this is how I verified. I used one step JCL and allocated a dataset using IEFBR14.

Code:

//STEP0100  EXEC  PGM=IEFBR14                   
//*                                             
//FILE01   DD  DSN=MYTID.EMPTY.TEST,           
//             DISP=(NEW,CATLG,DELETE),         
//             UNIT=SYSDA,                       
//             SPACE=(TRK,(1,1),RLSE),           
//             DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)
//*


Code:

IEF236I ALLOC. FOR MYTIDA STEP0100                             
IGD101I SMS ALLOCATED TO DDNAME (FILE01  )                       
        DSN (MYTID.EMPTY.TEST                          )       
        STORCLAS (BASE) MGMTCLAS (INTERIM) DATACLAS (DCDEFLT)   
        VOL SER NOS= DMASAK                                     
IEF142I MYTIDA STEP0100 - STEP WAS EXECUTED - COND CODE 0000   

I issued the following command in 3.4 besides the dataset name

Code:

LISTD / LABEL


The following is the output from the command.

Code:

MYTID.EMPTY.TEST               
--RECFM-LRECL-BLKSIZE-DSORG     
  FB    80    27920   PS         
--VOLUMES--                                                                 
  DMASAK                                                                     
--FORMAT 1 DSCB--                                                           
F1 C4D4C1E2C1D2 0001 67011B 000000 01 00 00 C9C2D4D6E2E5E2F24040404040       
00000090000000 4000 90 00 6D10 0050 00 0000 80 80000001 000000 E5A2 0000    
01000017000E0017000E 00000000000000000000 00000000000000000000 0000000000


The EOF file mark is stored on the second line(3rd field from the right) of FORMAT-1 DSCB.A value of 000000 means the file is empty.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Fri Oct 10, 2003 11:55 pm    Post subject: Reply with quote

Kolusu,

Thanx for the reply. It would be interesting to edit your file, adding then deleting a line of data, save the file, list the dscb again and then compare it to the original list.

Since ISPF edit will create the EOF indicator, and if SMF did the same, the lists should be the identical.

I'd do it myself, but unfortunately, I don't have access to a mainframe (that's a clever way of saying I'm out of work.) Mr. Green

Thanx, Jack.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Sat Oct 11, 2003 6:53 am    Post subject: Reply with quote

Jack,

I am very sorry to hear that you are out of job.I am really amazed with your posts which are error-free even though you cannot test the code. I wish I could be like you.

Ok I eidted the file by adding a couple of lines and saved it and then deleted all the records.

This is the output of the dscb now. The eof mark still shows zeroes.

Code:

--FORMAT 1 DSCB--                                                           
 F1 C4D4C1E2C1D2 0001 67011B 000000 01 00 00 C9C2D4D6E2E5E2F24040404040   
 67011CA0000000 4000 90 00 6D10 0050 00 0000 82 80000001 000000 E5A2 0000 
 01000017000E0017000E 00000000000000000000 00000000000000000000 0000000000


F1 C4D4C1E2C1D2 0001 67011B 000000 01 00 00 C9C2D4D6E2E5E2F24040404040
00000090000000 4000 90 00 6D10 0050 00 0000 80 80000001 000000 E5A2 0000
01000017000E0017000E 00000000000000000000 00000000000000000000 0000000000

Only on the second line 2 fields are changed which are highlighted in bold.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group