FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-3
Allocating Scratch Space
SORTBUILDPARM puts the parameters you specify in a sort control block, which is a
global array used for storing the information. SORTMERGESTART uses the sort
control block to pass the parameters to the SORTPROG process.
Allocating Scratch Space
You can have SORTPROG create initial and overflow scratch files for you. To do this,
specify either no scratch file in SORTMERGESTART or a disk file that does not exist.
If you want SORTPROG to use only a single, permanent scratch file, use the formula
described under Manually Creating a Scratch File on page 9-2 to calculate scratch file
size. Use FUP to create the file and then specify the file to FastSort in
SORTMERGESTART.
For example, if your input files have different maximum input record lengths, you might
want to manually estimate initial scratch file size. Rather than the maximum output
record length, multiply the number of input records by the average output record
length. Then tell SORTPROG to use your estimate by setting SORTMERGESTART
flags.<9> to 1.
Use the scratchvols structure in SORTBUILDPARM to specify volumes to include
or exclude from overflow scratch files. For more information about scratch files, see
Section 9, Optimizing Sort Performance. For more information about FUP, see the File
Utility Program (FUP) Reference Manual.
Getting Information About a Sort or Merge Run
To return information about the sort or merge run to your application, use these
procedures:
SORTMERGESTATISTICS
SORTERRORSUM
SORTMERGESTATISTICS provides details about the records and resource use after a
successful run. SORTERRORSUM returns all the information provided by
SORTERROR and SORTERRORDETAIL and identifies the cause of the most recent
error if not an input error. For more detailed information about statistics and error
messages, see Understanding Statistics
on page 2-13 and Understanding
Error Messages on page 2-14.
Specifying Input Records
The SORTPROG process reads records directly from one or more input files and
writes the records to an output file. Each input file can contain either sorted records for
merging or unsorted records for sorting and merging. When reading more than one
input file, SORTPROG uses the same key-field specifications for all input records.
Figure 4-1 on page 4-4 shows sorting and merging with input and output files.