FastSort Manual

Sorting Programmatically
FastSort Manual429834-003
4-13
Sorting From COBOL85 Programs
Sorting From COBOL85 Programs
When you use a SORT or MERGE statement in a COBOL85 program, COBOL85 calls
FastSort procedures. COBOL85 uses SORTMERGESEND and
SORTMERGERECEIVE record blocking for:
Input procedures and output procedures specified in SORT statements
Tape files specified in the USING phrase of SORT and MERGE statements
Tape files or multiple output files specified in the GIVING phrase of SORT and
MERGE statements
COBOL85 does not use record blocking for a program that runs as a process pair.
For tape input files, COBOL85 deblocks the records and uses the SORTMERGESEND
procedure to send them to SORTPROG. For tape output files, COBOL85 blocks the
records from SORTMERGERECEIVE. Instead of transferring a single record in each
interprocess message between the COBOL85 program process and SORTPROG,
FastSort transfers a block of input or output records in each message.
To run FastSort from a COBOL85 program, you use the COBOL85 utility library. This
library resides in the $SYSTEM.SYSTEM.COBOLLIB program file. For more
information about COBOLLIB, see the COBOL85 Reference Manual.
Example 4-2 on page 4-14 shows a COBOL85 example of a serial sort run. For a
COBOL85 example of a parallel sort run, see Section 6, Sorting in Parallel.
//*-------------------------------------------------------------*/
/* Call SORTMERGEFINISH to stop SORTPROG after the process */
/* successfully completes the current sort and merge run(s). */
/*-------------------------------------------------------------*/
error = SORTMERGEFINISH (&ctlblk[0]);
if (error) /* check for SORTMERGEFINISH error */
{
errlen = SORTERRORSUM (&ctlblk[0],
&error_buf[0],
&error_code[0],
&error_source[0]);
error_handler;
return EXIT_FAILURE;
}
FILE_CLOSE_ (home_term_filenum);
} /* End of Main logic */
void error_handler (void)
{
/* error handling stubbed out */
return;
}
short DisplaySortStatistics (struct sortstats_template *instats)
{
/* Printing of statistics stubbed out */
return EXIT_SUCCESS;
}
/*------------------------E-N-D--------------------------------*/
Example 4-1. C Example of a Serial Sort Run (page5of5)