View previous topic :: View next topic |
Author |
Message |
GaneshB Beginner

Joined: 03 Dec 2002 Posts: 17 Topics: 5 Location: Columbus, GA
|
Posted: Tue Dec 21, 2004 1:43 am Post subject: Delete Dataset if it is empty |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Tue Dec 21, 2004 5:42 am Post subject: |
|
|
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 |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Tue Dec 21, 2004 6:19 am Post subject: |
|
|
Wow, This is Excellent Kolusu.
Thanks,
Phantom |
|
Back to top |
|
 |
GaneshB Beginner

Joined: 03 Dec 2002 Posts: 17 Topics: 5 Location: Columbus, GA
|
Posted: Tue Dec 21, 2004 7:25 am Post subject: |
|
|
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 |
|
 |
|
|