ACUCOBOL-GT manages four types of file organization. These are:
- Sequential Files - are ordered by the historical order in which records are written to the file.
- Relative Files - contain records that are identified by their record number, where the first record in the file is record
number one. Relative files are ordered by ascending record numbers.
- Indexed Files - contain records that have one or more key fields. Records in an indexed file are ordered by ascending values
in these key fields. Each key of an indexed file represents an ordered sequence by which the records can be accessed. One
of the key fields, known as the primary key, must contain a unique value for each record and is used to identify records uniquely.
- Sort Files - are used only by the SORT, MERGE, RELEASE, and RETURN verbs. These are used to sort and merge records.
There are also four record types. These are:
- Fixed-length Records - these records are a constant size.
- Variable-length Records - these records contain information about the length of each record, which may vary.
- Text Records - are sequential file records that contain text data. Text files should generally contain only USAGE DISPLAY
fields, because the binary information contained in other types of fields may inadvertently resemble line-length delimiters
used by the host computer system (e.g., carriage return or line-feed characters). Text records may optionally have trailing
spaces automatically removed from them by the runtime system. This is determined by the device type named in the file's ASSIGN
- Print Records - are text records that additionally contain printer carriage control information. Only sequential files may
be print files. Print records have trailing blanks removed from them when they are written to the file. This is done to improve
printing performance for printers that use serial communications. Unless otherwise noted, a print file follows the same rules
as a text file.
The organization of a file is determined by the file's SELECT clause of the Environment Division and its FD or SD clause of
the Data Division. The record type is determined by the first of the following rules that applies:
- If the file's ASSIGN clause has the PRINT option, print records are used.
- If any WRITE statement that references the file contains the ADVANCING phrase, print records are used.
- If LINAGE is specified for the file, print records are used.
- If PRINT-CONTROL is specified, print records are used.
- If the file's SELECT has the LINE SEQUENTIAL clause, text records are used.
- If the file's device type is DISPLAY or KEYBOARD, text records are used.
- In RM/COBOL compatibility mode, if the file is sequential and
-Cb is not specified, text records are used.
- If the file's FD or SD contains a RECORD clause, variable-length records are used if the IS VARYING IN SIZE phrase is used
or if both a minimum and maximum record size is specified. If only a single record size is specified, then fixed-length records
Note: For objects compiled for runtimes earlier than version 10, the compiler has an internal restriction of at least 6 bytes for
SORT FILE records. If a record is shorter than that, the compiler detects it and pads the record to 6 bytes. Note also that
in versions prior to 5.0, using SORT FILE with records shorter than 6 bytes would cause crashes.
- If multiple record layouts are declared for the file and these records are not all the same size, variable-length records
- If the
-Cf flag is used, then any variable-length record is made fixed-length.
- If none of the preceding rules applies, then fixed-length records are used.