NO using the same dataset for SORTIN and SORTOUT is discouraged in general
it is not possible for VSAM in particular
it' s a more general paradigm ralated to VSAM rather than a DFSORT limitation
Yes, you're right that it is discouraged. And if we're talking about a COPY, then you're right that it can't be done. But if we're talking about a SORT, then it can be done with DFSORT. Garry is right about the requirements. To quote from the description of DFSORT's VSAMIO operand:
specifies that DFSORT can use the same VSAM data set for input and output when all of the following conditions are met:
o The application is a sort.
o RESET is in effect.
o The VSAM data set was defined with REUSE.
These conditions ensure that the VSAM data set is processed as NEW for output and will contain the sorted input records, that is, it will be sorted in-place.
DFSORT terminates if the same VSAM data set is specified for input and output and any of the above conditions are not met.
sort processing is based on a sequential processing approach
read input file,
process each record
write output file
That's the way it works for a copy. But for a sort, the process is to read the records from the input file, sort the records, and write the sorted records to the output file. If you think about it, you can't read, process, write for a sort because the last record in the input file could be the first record in the output file.