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 

Delete Dataset if it is empty

 
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
GaneshB
Beginner


Joined: 03 Dec 2002
Posts: 17
Topics: 5
Location: Columbus, GA

PostPosted: Tue Dec 21, 2004 1:43 am    Post subject: Delete Dataset if it is empty Reply with quote

Hi,

In step1 of my JCL, PGM X is creating 3 outputs. In step2, I want to
delete dataset created in step1 if any is empty.

Step1:
output1 - Empty
output2 - 2 recs
output3 - 3 recs

Step2:
Delete output1 as it is Empty.

I have searched and found lot of Topics to find a dataset is empty thru
IDCAMS, SORT & EZT and based on return code we can continue
process. For example I gave here as 3 outputs and in my job 15
datasets are created. I really dont want to acheive this by having
seperate step for each dataset and delete based on return codes as
more steps are required.

Is it possible to delete a dataset if it is empty thru any utility?
_________________
Regards,
Ganesh.B
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Dec 21, 2004 5:42 am    Post subject: Reply with quote

Ganeshb,

You can use IDCAMS to check if the file is empty and delete it in the same step itself. try this job

Code:

//STEP0100 EXEC PGM=IDCAMS             
//SYSPRINT DD SYSOUT=*                 
//FILE01   DD DSN=YOUR.OUTPUT.FILE01,
//            DISP=SHR                 
//FILE02   DD DSN=YOUR.OUTPUT.FILE02,
//            DISP=SHR                 
//FILE03   DD DSN=YOUR.OUTPUT.FILE03,
//            DISP=SHR                 
//SYSIN    DD *                                   
  PRINT INFILE(FILE01) CHARACTER COUNT(1)         
  IF LASTCC = 4 THEN DELETE 'YOUR.OUTPUT.FILE01'
  PRINT INFILE(FILE02) CHARACTER COUNT(1)         
  IF LASTCC = 4 THEN DELETE 'YOUR.OUTPUT.FILE02'
  PRINT INFILE(FILE03) CHARACTER COUNT(1)         
  IF LASTCC = 4 THEN DELETE 'YOUR.OUTPUT.FILE03'
/*


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Dec 21, 2004 6:19 am    Post subject: Reply with quote

Wow, This is Excellent Kolusu.

Thanks,
Phantom
Back to top
View user's profile Send private message
GaneshB
Beginner


Joined: 03 Dec 2002
Posts: 17
Topics: 5
Location: Columbus, GA

PostPosted: Tue Dec 21, 2004 7:25 am    Post subject: Reply with quote

Kolusu,

Thanks a lot. Your JCL worked as expected.
I have just replaced PRINT INFILE with PRINT INDATASET as I dont
need to give the FILE01 to FILE10.
_________________
Regards,
Ganesh.B
Back to top
View user's profile Send private message Send e-mail
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
Page 1 of 1

 
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