Hi Mingo,
Yes, you understand this correctly.
It is not necessary to do anything with an input or output file at all when you do a sort.
The sort is done with the SD file. It has only a relation with in- or output when you create this in your statement.
Look at the syntax of the SORT statement:
3.32 SORT Statement
Ü Copyright IBM Corp. 1984, 1993
The SORT statement accepts records from one or more files, sorts them
according to the specified key(s), and makes the sorted records available
either through an OUTPUT PROCEDURE or in an output file. See also "MERGE
Statement" in topic 3.21. The SORT statement can appear anywhere in the
| Procedure Division except in the declarative portion or within the scope
| of a SORT or MERGE input or output procedure.
|--- Format -----------------------------------------------------------------------------------|
| |
| <--------------------------------------------------| |
| <-------------| | |
| >>--SORT--file-name-1----|----|--|-ASCENDING--|--|-----|----data-name-1-|-|----------------> |
| |-ON-| |-DESCENDING-| |-KEY-| |
| |
| >--|-----------------------------------------|---------------------------------------------> |
| |-|------|--DUPLICATES--|----|--|-------|-| |
| | |-WITH-| |-IN-| |-ORDER-| |
| |
| >--|--------------------------------------------------|------------------------------------> |
| |-|-----------|--SEQUENCE--|----|--alphabet-name-1-| |
| |-COLLATING-| |-IS-| |
| |
| <-------------| |
| >--|-USING----file-name-2-|-------------------------------------------------------|--------> |
| |-INPUT PROCEDURE--|----|--procedure-name-1--|-------------------------------|-| |
| |-IS-| |-|-THROUGH-|--procedure-name-2-| |
| |-THRU----| |
| |
| <-------------| |
| >--|-GIVING----file-name-3-|-------------------------------------------------------|------>< |
| |-OUTPUT PROCEDURE--|----|--procedure-name-3--|-------------------------------|-| |
| |-IS-| |-|-THROUGH-|--procedure-name-4-| |
| |-THRU----| |
| |
|----------------------------------------------------------------------------------------------|
file-name-1
The name given in the SD entry that describes the records to be
sorted.
No pair of file-names in a SORT statement can be specified in the same
SAME SORT AREA, or SAME SORT-MERGE AREA clause. File-names associated with
the GIVING clause (file-name-3) cannot be specified in the SAME AREA
clause.
x File-names associated with the GIVING clause (file-name-3) can be
x specified in the SAME AREA clause.
This is clipped out of a IBM manual.
You can use the given example to sort things your own way.
You can put any keyfield and others too of course inside the record to sort.
[sig][/sig]