Field Types

The following is a list of some of the available field types:

Field Type Definition
AQ Character with alternate collating sequence.
BI COMP
C5 COMP-5
C6 COMP-6
CH PIC X DISPLAY
CX COMP-X
FL Floating point, signed.
FS/CSF Signed numeric, with optional leading floating sign.
LI/OL/CLO PIC S9 LEADING INCLUDED
LS/CSL PIC S9 LEADING SEPARATE
NU PIC 9 DISPLAY
PD PIC S9 COMP-3
PD0 Packed decimal with first semi-byte and sign semi-byte ignored.
SB/FI PIC S9 COMP
S5 S9 COMP-5
SFF Signed free form numeric
SS Substring. Used in conditions only.
TS/CST PIC S9 TRAILING SEPARATE
TI/ZD/OT/CTO PIC S9 TRAILING INCLUDED
UFF Unsigned free form numeric
Y2B Two-digit, one-byte binary year data.
Y2C/Y2Z Two-digit, two-byte year data, with optional trailing included sign. PIC 99 or PIC S99.
Y2D Two-digit, one-byte packed decimal year data. PIC 99 COMP-6.
Y2P Two-digit, two-byte packed decimal year data. PIC 99 COMP-3.
Y2S Two-digit, two-byte character year data with special indicators. Binary zeros, blanks and binary ones are treated as special cases.
Y2T Full date format, yyx...
Y2U Full date format, yyx..., COMP-3.
Y2V Full date format, yyx..., COMP-3. Ignores first semi-byte.
Y2W Full date format, x...yy.
Y2X Full date format, x...yy, COMP-3.
Y2Y Full date format, x...yy, COMP-3. Ignores first semi-byte.

You can find other field types defined in the IBM documentation at SORT Control Statement.

Suppose that golf.dat is a relative file defined in a COBOL program as follows:

 file-control.
     select members-file
         assign to "d:\netexpress\base\workarea\golf.dat"
         organization is relative
         access mode is random
         relative key is relative-key.
 data division.
 file section.
 fd members-file
     record contains 28 characters.
 01 members-record.
     03 members-number pic 9(6).
     03 members-lname pic x(10).
     03 members-fname pic x(10).
     03 members-handicap pic 9(2).

You can then use the following mfsort command to sort the file golf.dat on the field containing the membership number in ascending order:

mfsort sort fields(1,6,nu,a)
   use golf.dat record f,28 org rl
   give members.dat

The sorted version of the file is written to the file members.dat.