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
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 ')
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.
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.
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.
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.