HP 3000 Manuals

General Structures [ Micro Focus COBOL System Reference, Volume 2 ] MPE/iX 5.0 Documentation


Micro Focus COBOL System Reference, Volume 2

General Structures 

There are three basic structures used for all files:  line sequential,
fixed and variable.

Line sequential is the structure of files with the line sequential
organization.  It contains variable length records with trailing spaces
removed.

Fixed is the structure used by fixed format sequential and relative
files, and contains only fixed length records.

Variable is the structure of variable format sequential and relative
files, and fixed and variable format indexed files.  Variable structure
files can contain fixed or variable length records.

The following sections describe these file formats.

Fixed and Variable Format 

The format of a file is determined by the RECMODE directive and the FD
clauses RECORDING MODE, RECORD CONTAINS n CHARACTERS and RECORD IS
VARYING. The RECORDING MODE clause overrides the RECORD clause which, in
turn, overrides the RECMODE directive.   

Hence:

   *   RECORDING MODE IS V always creates variable format.

   *   RECORDING MODE IS F always creates fixed format.

   *   RECORD CONTAINS a TO b CHARACTERS has no effect on file format.

   *   RECORD IS VARYING creates variable format provided no RECORDING
       MODE IS F clause is present.

   *   RECORD CONTAINS n CHARACTERS creates fixed format provided no
       RECORDING MODE IS V clause is present.

   *   RECMODE"F" creates fixed format for each file where no RECORDING
       MODE IS V or RECORD IS VARYING clauses are present.

   *   RECMODE"V" creates variable format for each file where no
       RECORDING MODE IS F or RECORD CONTAINS n CHARACTERS clauses are
       present.

   *   RECMODE"OSVS" causes the LEVEL-01 definitions to determine if the
       file is fixed or variable format.

Fixed |Structure 

Fixed structure files contain no record or file header information.  The
records are all the same length, that length being determined by the
longest record defined in the File Description (FD) in the program's
File-Section.

Variable Structure 

Any files containing variable length records, with the exception of line
sequential files and files destined for the printer, contain a block of
128 bytes of header information at the start of the file.  Each record in
the file is preceded by a 2- or 4-byte control field.  The top 4 bits of
this field indicate the status of the record.  A value of 0100 in these
bits means that this record is a user data record.  Any other value means
that this record has either been deleted or is used internally.  The
remainder of the control field contains the length of the record.

For all files where the maximum record size is less than 4096 (excluding
the prefix), the prefix is 2 bytes long.  For all other files, the prefix
is 4 bytes long.  Each record always starts on the next 4-byte boundary
in the file.

You must not alter the header information or the control fields in any
way since these are maintained by this COBOL system.

Record Header Types.   

First 4 bits Record type 

-------------------------------------------------

1 (0001)     A system record (IDXFORMAT"4" files
             only).

             This contains duplicate occurrence
             details in the data file.

2 (0010)     Deleted record (available for reuse
             via the Free Space list).

3 (0011)     System record.

4 (0100)     User data record.

5 (0101)     Reduced user data record (indexed
             files only).

             The 16-bit word immediately
             following the data record, as
             indicated by the length in the
             header, contains the space between
             the end of the data record and the
             start of the next record header.

6 (0110)     Pointer record (indexed files only).

             The first 4 bytes following the
             record header contain the offset in
             the file to the location of the user
             data record.

7 (0111)     User data record referenced by a
             Pointer record.

8 (1000)     Reduced user data record referenced
             by a Pointer record.

The first record in every variable structure file is a system record
called the File Header record.  This is normally 128 bytes long.

The record header for each record starts on a 4-byte boundary.
Consequently, a record may be followed by up to three padding characters,
usually spaces.  These padding characters are not included in the record
length.

Variable structure File Header record description:

Offset Size        Description of the field 

-------------------------------------------------

0      4     Length of the file header.

             The first 4 bits are always set to 3
             (0011 in binary) indicating that
             this file header record is a system
             record.

             The remaining bits contain the
             length of the file header record.
             If the maximum record length is less
             than 4095 bytes, the length is 126
             and is held in the next 12 bits;
             otherwise it is 124 and is held in
             the next 28 bits.  Hence, in a file
             where the maximum record length is
             less than 4095 bytes, this field
             contains x"30 7E 00 00".  Otherwise,
             this field contains x"30 00 00 7C".

4      2     Database sequence number, used by
             add-on products supplied with this
             COBOL system.

6      2     Integrity Flag.  Indexed files only.

             If this is non-zero when the header
             is read, it indicates that the file
             is corrupt.

8      14    Creation date and time in
             YYMMDDHHMMSSCC format.  Indexed
             files only.

22     14    Reserved.

36     2     Reserved.  Value 62 decimal; x"00
             3E".

38     1     Not used.  Set to zeros.

39     1     Organization.

             1 = Sequential
             2 = Indexed
             3 = Relative

40     1     Not used.  Set to zeros.

          Table I-0.  (cont.) 

Offset Size        Description of the field 

41     1     Data compression routine number.

             0 = No compression
             1 = CBLDC001
             2-127 = Reserved for internal use
             128-255 = User-defined compression
             routine
             number

42     6     Not used.  Set to zeros.

43     1     File format.

             0 = Default
             1 = C-ISAM
             2 = LEVEL II COBOL
             3 = Indexed file format used
             by this COBOL system
             4 = IDXFORMAT"4"

44     4     Reserved.

48     1     Recording mode.

             0 = Fixed format
             1 = Variable format

             For indexed files, the Recording
             Mode field of the index file takes
             precedence.

49     5     Not used.  Set to zeros.

54     2     Not used.  Set to zeros.

56     2     Maximum record length.

             Example:  with a maximum record of
             length 80 characters, this field
             will contain x"00 50".

58     2     Not used.  Set to zeros.

60     2     Minimum record length.

             Example:  with a maximum record of
             length 2 characters, this field will
             contain x"00 02".

62     46    Not used.  Set to zeros.

          Table I-0.  (cont.) 

Offset Size        Description of the field 

108    4     Version and build data for the
             indexed file handler creating the
             file.  Indexed files only.

112    16    Not used.  Set to zeros.



MPE/iX 5.0 Documentation