Joined: 27 Apr 2005 Posts: 43 Location: United States
Hi,
I have a lot of empty datasets after a after running a DFSort. Is there a special technique to delete these dataset in a following JCL step, or a way to not catalog them if they are empty during the sort?
Currently my Sort Sysin looks like this:
//SYSIN DD DATA
SORT FIELDS=(9,4,CH,A,121,4,CH,A,86,10,CH,A,46,4,CH,A)
MERGE FIELDS=COPY
OUTFIL FILES=1,INCLUDE=(9,4,CH,EQ,C'AU ')
OUTFIL FILES=2,INCLUDE=(9,4,CH,EQ,C'SH ')
OUTFIL FILES=3,INCLUDE=(9,4,CH,EQ,C'PW ')
OUTFIL FILES=4,INCLUDE=(9,4,CH,EQ,C'SS ')
OUTFIL FILES=5,INCLUDE=(9,4,CH,EQ,C'AN ')
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
I'd be very interested to hear if somebody has an easy way to do this.
It would probably be possible to check each output file to see if it's empty and if so generate the JCL or a control statement (IEHPROGM?) to delete it, but it seems like there really should be a better way. I don't do this kind of thing myself, so I'm not aware of a simple solution.
BTW, MERGE FIELDS=COPY will do a COPY - your SORT statement will be ignored.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
use icetool program itself to copy the 1st record of sorted data set into another....if its empty it will give a RC of 8 and delte if its empty.
ICETOOL COPY does NOT set RC=8 if a file is empty and does NOT automatically delete an empty file. ICETOOL COUNT or NULLOUT can be used to force a non-zero return code for an empty data set, but the question still remains of how you "translate" that to the action of deleting the empty file.
Joined: 05 May 2005 Posts: 98 Location: Navi Mumbai, India
You put an if stmt like - if RC = 8 then execute the delete step.
Also you can compare the files produced with an empty file. If its true then delete the file produced.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
You put an if stmt like - if RC = 8 then execute the delete step.
I think you're missing the point. The DFSORT step produces multiple output data sets. Some of them may be empty and some of them may not be empty. Only the empty data sets are to be deleted. DFSORT's NULLOFL parameter can set a RC=16 if any of the output data sets is empty. But if we use that RC=16 to execute the delete step, it will delete the non-empty data sets as well as the empty data sets. The challenge here is to find a way to delete ONLY the empty data sets without deleting the non-empty data sets.
Of course this could be done by using a step that creates one output data set followed by a step that deletes the output data set if its empty, and repeating for each output data set. But what the poster wants is a way to delete only the empty output data sets after a step that creates multiple output data sets, each of which may or may not be empty.
Joined: 27 Apr 2005 Posts: 419 Location: Inside the SPEW (Southwest Ohio, USA)
Frank,
I think Ankur's method will work, but it does require two additional steps per output file.
First step is the Fileaid step to set the RC and followed by second step which is executed only upon RC=8 from first step and is and pgm=IEFBR14 with a MOD,DELETE,DELETE for the empty DSN.
Repeat for each output file.
In this case 5 output files from SORT step require additional 10 steps to achieve the desired result.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You don't need FileAid to set the RC. You can use the COUNT operator of DFSORT's ICETOOL to do that. But I really think the whole idea here was to avoid having to do multiple steps for each output file. The original poster said "Is there a special technique to delete these dataset in a following JCL step". "step" here is singular. Or maybe I'm reading too much into it. If any number of steps will do, then it's easy.
May be you guys already found a easier solution, but if this is of any worth. You can do multiple files in the same step. A RC of 4 implies an empty file.
Code:
//STEP001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT INDATASET ('DSS1') COUNT(1)
IF LASTCC=4 -
THEN DELETE DSS1
PRINT INDATASET ('DSS2') COUNT(1)
IF LASTCC=4 -
THEN DELETE DSS2
SET MAXCC=0