COBOL2000 supports sorting and merging with the following language elements (see “COBOL2000 Reference Manual” [1]):
Specification of the literal “SORTWK” in the ASSIGN clause:
This explicitly declares the link name SORTWK for the sort file.
The format of the ASSIGN clause for sort files also permits other specifications, but these are treated as comment entries by the compiler. The link name for the sort file is always SORTWK.
The sort file description entry (SD) in the Data Division
This corresponds to the file description entry (FD) for other files and defines the physical structure, the format and the size of the records.
The SORT and MERGE statements in the Procedure Division:
input procedure. The sorted records are written to a file or transferred SORT sorts records by one or more data items (up to 64), specified as sort keys.
These data records can be made available to SORT from a file or via an to an output procedure.For sorting, COBOL2000 uses the sorting function of the BS2000 utility SORT for sorting (see “Sort” manual [6]).
MERGE merges records from two or more sorted input files in a sort file on the basis of a number of data items (up to 64) that have been specified as sort keys.The merged records are written to a file or transferred to an output procedure.
Declaration of input and output procedures
An input procedure (INPUT PROCEDURE phase) can be declared for any SORT statement. The procedure allows the records which are to be sorted to be generated or processed before they are passed to the sort file via a RELEASE statement.
An output procedure (OUTPUT PROCEDURE phase) can be declared for any SORT or MERGE statement. The procedure allows the sorted or merged records to be processed further, after they have been made available to it with a RETURN statement.
If desired, text can be sorted according to the DIN standard for EBCDIC. To this end, sort format ED of the SORT utility routine is selected for all SORT statements in a program by compiling the program with the SDF option RUNTIME-OPTIONS=PAR(SORTING-ORDER=BY-DIN) or, alternatively, with COMOPT SORT-EBCDIC-DIN=YES (see “Sort” manual [6]).
This means thatlowercase letters are equated with the corresponding uppercase letters and
the character
“ä” / “Ä” is identified with “AE”
“ö” / “Ö” is identified with “OE”
“ü” / “Ü” is identified with “UE”
“ß” is identified with “SS”
digits are sorted before letters