View previous topic :: View next topic
|
Author |
Message |
quanzhong
New User
Joined: 12 Aug 2008 Posts: 46 Location: china
|
|
|
|
Hi, all
now i want to batchly modify a KSDS file, I am using sort, and i want to using that file as both SORTIN and SORTOUT, is that possible? can someone give me a template?
thanks. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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
sort processing is based on a sequential processing approach
read input file,
process each record
write output file
in this case the logic that You migh use is
process the KSDS(SORTIN) writing a work file(SORTOUT)
delete/define the KSDS
repro back the work file into the empty KSDS |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Quote: |
it is not possible for VSAM in particular |
I believe you can do a destructive SORT if the VSAM file is defined with REUSE and DFSORT uses the OPTION RESET,VSAMIO.
That said, it's still not a good idea to risk losing your data this way.
Garry. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
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 |
Enrico,
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:
VSAMIO
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.
Quote: |
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. |
|
Back to top |
|
|
|