COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
The open and close operations are equivalent to OPEN OUTPUT and CLOSE statements
having no optional phrases.
All of these implicit functions are performed such that any associated declarative
procedures are executed; however, the execution of a declarative procedure must not
cause the execution of any statement that manipulates any of the output files or accesses
the record area associated with any output file.
When more than one instance of outfile is specified, each operation is performed on
each file in the order that they appear in the GIVING phrase. That is, the output files are
opened in order, each retrieved record is written to each file in order, and then the files
are closed in order.
If an output file is a relative file, the relative key data item is set to the value 1 for the first
record returned, 2 for the second, and so forth. After the SORT statement finishes executing,
the content of the relative key data item indicates the last record returned to the file.
If an output file has fixed-length records, each record retrieved from the sort file containing
fewer character positions than the fixed size specified for the output file is extended on
the right with as many space characters as needed before it is written to the output file.
The first attempt to write beyond the defined boundaries of an output file causes a
boundary violation condition. This in turn causes the execution of the applicable USE
procedure, if one exists.
The sort operation automatically closes the sort file after the end of the output phase. Then
the SORT statement terminates execution.
◦ OUTPUT PROCEDURE Phrase
If the OUTPUT PROCEDURE phrase appears, the output phase executes an implicit
PERFORM procedure-group statement (where procedure-group is the procedure
name, optionally followed by THROUGH or THRU and another procedure name). The
sort output procedure thereby specified is responsible for retrieving the sort file records
by one or more executions of RETURN statements. The sort output procedure must not
open the sort input file infile. Control automatically returns to the sort operation after
execution passes beyond the last statement in the range of the PERFORM statement.
The range of the output procedure must not cause the execution of a MERGE, RELEASE,
or SORT statement or a RETURN statement that references any sort or merge file other
than the one identified by sd-name.
• Sort Scratch File
The FastSort utility determines the default scratch file size if the file-system file named in the
file-control entry does not exist. If the file does exist, SORT uses it. You can use the File Utility
Program CREATE or command interpreter CREATE command to create the scratch file on disk.
If the sort input file is defined to be on tape, or if the sort receives its records from an input
procedure, the default number of records in the scratch file is 50K.
SORT deletes the scratch file after it completes ordering the records unless you specify
SAVE-SCRATCH in the routine COBOL85^SET^SORT^PARAM^VALUE or
COBOL_SET_SORT_PARAM_VALUE_.
Example 133 Typical Use of Input and Output Procedures
FILE-CONTROL.
SELECT EMPLOYEE-MASTER ASSIGN TO "EMPMST"
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
SELECT SORT-WORK ASSIGN TO "SORTWORK".
DATA DIVISION.
FD EMPLOYEE-MASTER
448 Procedure Division Verbs










