SORT/MERGE Instructions

The SORT and MERGE instructions specify whether to perform a sort or merge operation. These two functions are mutually exclusive. A SORT or MERGE instruction must be followed by a FIELDS phrase that indicates the fields on which a file is to be sorted or merged. You specify the start position, the length, the type, and the order for each sort field. Use a comma to separate field attributes and a comma before starting to describe a new field. A merge operation combines records from files that are already sorted on the specified fields. The syntax for these functions follows:

acusort sort fields(start, length, type, order) 

acusort merge fields(start, length, type, order) 

where

start is the offset of the field in the record (in bytes, starting at position 1).
length is the size of the field in bytes.
type is a two-letter code indicating the type of data in the field (see the data field type descriptions below).
order is the order of output, either ascending (A) or descending (D).

The following data field types are supported in AcuSort:

BI Unsigned numeric, USAGE COMP
C5 Unsigned numeric, USAGE COMP-5
C6 Unsigned numeric, USAGE COMP-6
CH Alphanumeric
CX Usage COMP-X
FL Usage floating point
LI Signed numeric, SIGN IS LEADING
LS Signed numeric, SIGN IS LEADING SEPARATE
NU Unsigned numeric
PD Signed numeric, USAGE COMP-3
SB Signed numeric, USAGE COMP
S5 Signed numeric, USAGE COMP-5
TS Signed numeric, SIGN IS TRAILING SEPARATE
TI Signed numeric, SIGN IS TRAILING

In the following example:

acusort sort fields (1, 10, ch, a)

the sort operation begins at position 1 in a 10-byte sort field, and the alphanumeric data are sorted in ascending order. See AcuSort Code Sample for more sample code.

Note: When using LI or TI data types, you should be aware of the sign storage for your data. The AcuSort utility supports both IBM and Micro Focus sign storage. In ACUCOBOL-GT, use the Dci compile option to specify IBM sign storage, or the -Dcm option to specify Micro Focus sign storage. If you use IBM sign storage and your data is ASCII, use the SIGN-EBCDIC instruction in your take file of AcuSort options. See Data Storage Options in the ACUCOBOL-GT User's Guide for more information about data storage compile options. See USAGE Clause in the ACUCOBOL-GT Reference Manual for details on how signs are stored when the various compile options are used.