VMS Help  —  COBOL  ENVIRONMENT_DIVISION, FILE-CONTROL
  The FILE-CONTROL paragraph contains the file-related specifications.

1  –  1format_sequential

  FILE-CONTROL.

  Format 1 - Sequential File

   SELECT [OPTIONAL] file-name

      { ASSIGN TO  [ EXTERNAL ] file-spec     }
      {            [ DYNAMIC  ]               }
      {                                       }
      { ASSIGN TO  [ EXTERNAL ] { data-name } }
      {            [ DYNAMIC  ] { literal   } }
      {                         { DISK      } }
      {                         { PRINTER   } }

      [ RESERVE reserve-num [ AREA  ] ]
      [                     [ AREAS ] ]

      [ [ ORGANIZATION IS ] SEQUENTIAL ]

      [ BLOCK CONTAINS [smallest-block TO] blocksize { RECORDS    } ]
      [                                              { CHARACTERS } ]

      [CODE-SET IS alphabet-name]
      [PADDING CHARACTER IS pad-char]
      [RECORD DELIMITER IS STANDARD-1]
      [ACCESS MODE IS SEQUENTIAL]

      [LOCK MODE IS { AUTOMATIC [WITH LOCK ON RECORD] } ]
      [             { EXCLUSIVE                       } ]

      [FILE STATUS IS file-stat] .

2  –  2format_line_sequential

  FILE-CONTROL.

  Format 2 - Line Sequential File

   SELECT [OPTIONAL] file-name

      { ASSIGN TO  [ EXTERNAL ] file-spec     }
      {            [ DYNAMIC  ]               }
      {                                       }
      { ASSIGN TO  [ EXTERNAL ] { data-name } }
      {            [ DYNAMIC  ] { literal   } }
      {                         { DISK      } }
      {                         { PRINTER   } }

      [ RESERVE reserve-num [ AREA  ] ]
      [                     [ AREAS ] ]

      [ [ ORGANIZATION IS ] LINE SEQUENTIAL ]

      [ BLOCK CONTAINS [smallest-block TO] blocksize { RECORDS    } ]
      [                                              { CHARACTERS } ]

      [CODE-SET IS alphabet-name]
      [PADDING CHARACTER IS pad-char]
      [RECORD DELIMITER IS STANDARD-1]
      [ACCESS MODE IS SEQUENTIAL]

      [LOCK MODE IS { AUTOMATIC [WITH LOCK ON RECORD] } ]
      [             { EXCLUSIVE                       } ]

      [FILE STATUS IS file-stat] .

3  –  3format_relative

  FILE-CONTROL.

  Format 3 - Relative File

   SELECT [OPTIONAL] file-name

      { ASSIGN TO  [ EXTERNAL ] file-spec     }
      {            [ DYNAMIC  ]               }
      {                                       }
      { ASSIGN TO  [ EXTERNAL ] { data-name } }
      {            [ DYNAMIC  ] { literal   } }
      {                         { DISK      } }
      {                         { PRINTER   } }

      [ RESERVE reserve-num [ AREA  ] ]
      [                     [ AREAS ] ]

      [ ORGANIZATION IS ] RELATIVE

      [ BLOCK CONTAINS [smallest-block TO] blocksize { RECORDS    } ]
      [                                              { CHARACTERS } ]

      [RECORD DELIMITER IS STANDARD-1]

      [                { SEQUENTIAL [RELATIVE KEY IS rel-key] } ]
      [ ACCESS MODE IS { { RANDOM  } RELATIVE KEY IS rel-key  } ]
      [                { { DYNAMIC }                          } ]

      [             { MANUAL WITH LOCK ON MULTIPLE RECORDS } ]
      [LOCK MODE IS { AUTOMATIC [WITH LOCK ON RECORD]      } ]
      [             { EXCLUSIVE                            } ]

      [FILE STATUS IS file-stat] .

4  –  4format_indexed

  FILE-CONTROL.

  Format 4 - Indexed File

   SELECT [OPTIONAL] file-name

      { ASSIGN TO  [ EXTERNAL ] file-spec     }
      {            [ DYNAMIC  ]               }
      {                                       }
      { ASSIGN TO  [ EXTERNAL ] { data-name } }
      {            [ DYNAMIC  ] { literal   } }
      {                         { DISK      } }
      {                         { PRINTER   } }

      [ RESERVE reserve-num [ AREA  ] ]
      [                     [ AREAS ] ]

      [ ORGANIZATION IS ] INDEXED

      [ BLOCK CONTAINS [ smallest-block TO ] blocksize { RECORDS    } ]
      [                                                { CHARACTERS } ]

      [RECORD DELIMITER IS STANDARD-1]

      [                { SEQUENTIAL } ]
      [ ACCESS MODE IS { RANDOM     } ]
      [                { DYNAMIC    } ]

      [RECORD KEY IS { rec-key | seg-key = {seg}... }             ]
      [                          [WITH DUPLICATES] [ ASCENDING  ] ]
      [                                            [ DESCENDING ] ]

      [ALTERNATE RECORD KEY IS { alt-key | seg-key = {seg}... }   ]
      [                          [WITH DUPLICATES] [ ASCENDING  ] ]
      [                                            [ DESCENDING ] ] ...

      [             { MANUAL WITH LOCK ON MULTIPLE RECORDS } ]
      [LOCK MODE IS { AUTOMATIC [WITH LOCK ON RECORD]      } ]
      [             { EXCLUSIVE                            } ]

      [FILE STATUS IS file-stat] .

5  –  5format_sort-merge

  FILE-CONTROL.

  Format 5 - Sort or Merge File

   SELECT file-name

      { ASSIGN TO  [ EXTERNAL ] file-spec     }
      {            [ DYNAMIC  ]               }
      {                                       }
      { ASSIGN TO  [ EXTERNAL ] { data-name } }
      {            [ DYNAMIC  ] { literal   } }
      {                         { DISK      } }
      {                         { PRINTER   } }

6  –  6format_report

  FILE-CONTROL.

  Format 6 - Report File

   SELECT file-name

      { ASSIGN TO  [ EXTERNAL ] file-spec     }
      {            [ DYNAMIC  ]               }
      {                                       }
      { ASSIGN TO  [ EXTERNAL ] { data-name } }
      {            [ DYNAMIC  ] { literal   } }
      {                         { DISK      } }
      {                         { PRINTER   } }

      [ RESERVE reserve-num [ AREA  ] ]
      [                     [ AREAS ] ]

      [ [ ORGANIZATION IS ] SEQUENTIAL ]

      [ BLOCK CONTAINS [smallest-block TO] blocksize { RECORDS    }]
      [                                              { CHARACTERS }]

      [CODE-SET IS alphabet-name]
      [PADDING CHARACTER IS pad-char]
      [RECORD DELIMITER IS STANDARD-1]
      [ACCESS MODE IS SEQUENTIAL]
      [FILE STATUS IS file-stat] .

7  –  clauses

7.1  –  ASSIGN

  The ASSIGN clause associates a file with a partial or a complete
  file specification.

  Format -

   ASSIGN TO file-spec

7.1.1  –  file-spec

  is a nonnumeric literal or a COBOL word formed according to the
  rules for user-defined names.  It represents a partial or complete
  file specification.

7.2  –  BLOCK_CONTAINS

  The BLOCK CONTAINS clause specifies the size of a physical record.

  Format -

   BLOCK CONTAINS [smallest-block TO] blocksize { RECORDS    }
                                                { CHARACTERS }

7.2.1  –  smallest-block

  is an integer literal.  It specifies the minimum physical record
  size.

7.2.2  –  blocksize

  is an integer literal.  It specifies the exact or maximum physical
  record size.

7.3  –  CODE-SET

  The CODE-SET clause specifies the representation of data on external
  media.

  Format -

   CODE-SET IS alphabet-name

7.3.1  –  alphabet-name

  is the name of a character set defined in the SPECIAL-NAMES
  paragraph.  It cannot be described with literals in the ALPHABET
  clause.

7.4  –  LOCK_MODE

  The LOCK MODE clause specifies a locking technique to use for a
  file. LOCK MODE is part of the X/Open COBOL standard.

  Format -

      [             { MANUAL WITH LOCK ON MULTIPLE RECORDS } ]
      [LOCK MODE IS { AUTOMATIC [WITH LOCK ON RECORD]      } ]
      [             { EXCLUSIVE                            } ]

7.5  –  ORGANIZATION

  The ORGANIZATION clause specifies a file's logical structure.

  Format -

                       { SEQUENTIAL      }
   [ ORGANIZATION IS ] { LINE SEQUENTIAL }
                       { RELATIVE        }
                       { INDEXED         }

7.6  –  PADDING_CHARACTER

  The PADDING CHARACTER clause specifies the character to be used to
  pad blocks in sequential files.

  Format -

   PADDING CHARACTER IS pad-char

7.6.1  –  pad-char

  is a one-character nonnumeric literal or the data-name of a
  one-character data item.  The data-name can be qualified.

7.7  –  RECORD_DELIMITER

  The RECORD DELIMITER clause indicates the method of determining the
  length of a variable record on the external medium.  It is for
  documentation only.

  Format -

   RECORD DELIMITER IS STANDARD-1

7.8  –  RESERVE

  The RESERVE clause specifies the number of input-output buffers for
  a file.

  Format -

   RESERVE reserve-num [ AREA  ]
                       [ AREAS ]

7.8.1  –  reserve-num

  is an integer literal from 1 through 127.  It specifies the number
  of input-output areas for the file.
Close Help