Input-Output Section COBOL

The Input-Output section names the files and external media required by an object program and provides information required for transmission and handling of data during execution of the object program. This section is divided into two paragraphs:

  1. The FILE-CONTROL paragraph, which names and associates the files with external media.
  2. The I-O-CONTROL paragraph , which defines special control techniques to be used in the object program.

Input-Output Section

FILE-CONTROL Paragraph

The FILE-CONTROL paragraph names each file and allows specification of other file-related information.

The content of file-control-entry-1 depends on the organization of the file named. In addition, there is a separate form for a sort-merge file.

File Control Entry

The file control entry names a sequential, relative, or indexed organization file and provides other file-related information.

File Control Entry

File Control Entry

SELECT Clause

SELECT Clause

The SELECT clause must be specified first in the file control entry. The clauses that follow may appear in any order.

If the file connector referenced by file-name-1 is an external file connector, all file control entries in the run unit which reference this file connector must have:

  • The same specification for the OPTIONAL phrase.
  • A consistent specification for device-name-1 in the ASSIGN clause. The file access name specified in the ASSIGN clause, literal-1 or data-name-1, or in the VALUE OF clause should also be consistent, but the file access name specified by the program that executes the OPEN statement for file-name-1 will be used.
  • The same RECORD DELIMITER specification.
  • The same value for integer-1 and the same presence or absence of the ALTERNATE phrase in the RESERVE clause.
  • The same organization.
  • The same access mode.
  • The same lock mode.
  • The same character set for the CODE-SET clause.
  • The same specification for the PADDING CHARACTER clause.
  • The same external data item for data-name-3 in the RELATIVE KEY phrase.
  • The same collating sequence for the COLLATING SEQUENCE clause.
  • The same data description entry for data-name-4 or each data-name-5, the same number of data-name-5 in the definition of split-key-name-1 , the same relative location within the associated record for data-name-4 or each data-name-5, and the same presence or absence of the DUPLICATES phrase.
  • The same data description entry for data-name-6 or each data-name-7, the same number of data-name-7 in the definition of split-key-name-2, the same relative location within the associated record for data-name-6 or each data-name-7, the same presence or absence of the DUPLICATES phrase, and the same number of alternate record keys.

The OPTIONAL phrase applies to files opened in input, I-O, or extend modes. Its specification is required for files that may not be present each time they are opened for input, I-O, or extend.

The NOT OPTIONAL phrase is redundant commentary because, by default, files are not optional, that is, files are required to be present each time they are opened for input, I-O, or extend. The phrase is supported only for compatibility with other COBOL dialects that include this phrase.

Each file described in the Data Division must be named once and only once as file-name-1 in the FILE-CONTROL paragraph. Each file specified in a file control entry must have a file description entry in the Data Division of the same program.

ACCESS MODE Clause

ACCESS MODE Clause

The ACCESS MODE clause specifies the order in which records are to be accessed in the file.If the ACCESS MODE clause is not specified,ACCESS MODE IS SEQUENTIAL is implied.

If the access mode is sequential, records in the file are accessed in the sequence dictated by the file organization:

  • For sequential files, this sequence is specified by predecessor-successor record relationships established by the execution of WRITE statements when the file is created or extended.
  • For relative files, this sequence is the order of ascending or descending relative record numbers of existing records in the file.
  • For indexed files, this sequence is ascending or descending within a given key of reference according to the collating sequence of the file.

If the access mode is random, records in the file are accessed according to a key dictated by the file organization:

  • For sequential files, random access may not be specified.
  • For relative files, this key is the value of the relative key data item specified by data-name-3 in the RELATIVE KEY phrase. The RELATIVE KEY phrase is required when RANDOM is specified in the ACCESS MODE clause for a relative file.
  • For indexed files, this key is the value of a record key data item for the file. The random access mode is not recommended for indexed files that are described with the DUPLICATES phrase in the RECORD KEY clause. If the DUPLICATES phrase is specified in the RECORD KEY clause of the file control entry, then DELETE and REWRITE statements are not allowed in the random access mode, and READ statements can only access the first of a set of records with the same prime record key value.

If the access mode is dynamic, records in the file may be accessed sequentially or randomly as described in the rules for the input-output statements. Dynamic access may not be specified for sequential organization files. The RELATIVE KEY phrase is required when DYNAMIC is specified in the ACCESS MODE clause for a relative file.

The RELATIVE KEY phrase may only be specified in the ACCESS MODE clause of a file control entry that describes a relative organization file. If the access mode is random or dynamic, the RELATIVE KEY phrase must be specified within the ACCESS MODE clause for a relative file. Also, if a relative file is referenced in a START statement, the RELATIVE KEY phrase within the ACCESS MODE clause must be specified for that file. The relative key data item associated with the execution of an input-output statement for a relative file is the data item referenced by data-name-3 in the RELATIVE KEY phrase of the ACCESS MODE clause.

All records stored in a relative file are uniquely identified by relative record numbers. The relative record number of a given record specifies the record logical ordinal position in the file. The first logical record has a relative record number of 1, and subsequent logical records have relative record numbers of 2, 3, 4, and so forth.

The data item specified by data-name-3 is used to communicate a relative record number between the user and the mass storage control system (MSCS).data-name-3 may be qualified.data-name-3 must reference an unsigned integer data item whose description does not contain the PICTURE symbol Pdata-name-3 must not be defined in a record description entry associated with file-name-1. If data-name-3 is specified, is not qualified, and is not defined in the Data Division, the compiler assumes a Working-Storage Section data description entry of the following form:

Storage Section data description entry

If the associated file connector is an external file connector, every file control entry in the run unit that is associated with that file connector must specify the same access mode. In addition, for relative files, data-name-3 must reference an external data item and the RELATIVE KEY phrase in each associated file control entry must reference that same external data item in each case.

ASSIGN Clause

ASSIGN Clause

The ASSIGN clause specifies the association of the file referenced by file-name-1 with a class of external storage devices as indicated by device-name-1. For sequential organization files, there are 18 permissible selections for device-name-1. They are CARD-PUNCH, CARD-READER, CASSETTE, CONSOLE, DISC, DISK, DISPLAY, INPUT, INPUT-OUTPUT, KEYBOARD, LISTING, MAGNETIC-TAPE, OUTPUT, PRINT, PRINTER, PRINTER-1, RANDOM, and TAPE. For relative and indexed organization files, one of the mass storage device names (DISC, DISK, or RANDOM) must be specified or implied.

The contexts in which file-name-1 is used in the rest of the program establish these constraints on the device-name-1that may be assigned:

  1. If the file is used in an OPEN I-O statement,or if a record of the file is used in a REWRITE statement,device-name-1 must be DISC, DISK or RANDOM. In this context these words are synonymous.
  2. If the file is used in an OPEN INPUT or READ statement, or if it appears in the USING list of a SORT or MERGE statement,device-name-1must be CARD-READER, CASSETTE, CONSOLE, DISC, DISK, INPUT,INPUT-OUTPUT, KEYBOARD, MAGNETIC-TAPE, RANDOM or TAPE.
  3. If the file is used in an OPEN EXTEND or OPEN OUTPUT statement,if it appears in the GIVING list of a SORT or MERGE statement, if it is used in a RERUN ON phrase, or if a record of the file is used in a WRITE statement, device-name-1 must be CARD-PUNCH, CASSETTE, CONSOLE, DISC, DISK, DISPLAY, INPUT-OUTPUT, MAGNETIC-TAPE, OUTPUT, PRINT, PRINTER, PRINTER- 1, RANDOM or TAPE.

The ASSIGN clause may also specify the file access name with literal-1 or as the contents of a data item identified by data-name-1. The file access name is the name used to identify the physical file when the program is run. See the file description entry VALUE OF clause for an alternative method of specifying the file access name. If neither the ASSIGN clause nor the VALUE OF clause specify a file access name, then file-name-1 is used for the file access name. In any case, the value of the file access name must be valid according to operating system dependent rules for identifying a file or device. If the file access name is specified by a literal in the program, portability is more likely if the file access name is short (eight or fewer characters) and contains only letters and digits. Most operating systems provide a means to map such file access names to the longer names necessary to identify a particular physical file.

If literal-1 is specified,it must be a nonnumeric literal.

When the file access name is specified by data-name-1 or literal-1, device-name-1 may be omitted and the compiler will infer the storage device type from the organization of the file and the I-O statements used in the program. If file-name-1 refers to an external file connector for a sequential file, the compiler will assume a mass storage device when device-name-1 is omitted.

If data-name-1 is specified, it must be defined in the Data Division as a data item of the category alphanumeric. The value of this data item is used as the file access name at the time an OPEN statement is executed for the file. If data-name-1 refers to a variable length group, the maximum size of the group will be used to determine the file access name, independent of the value of the DEPENDING ON data item.data-name-1 may be qualified. If data-name-1 is specified, is not qualified,and is not defined in the Data Division, the compiler assumes a Working-Storage Section data description entry of the following form:

Storage Section data description entry

CODE-SET Clause

CODE-SET IS alphabet-name-1

The CODE-SET clause specifies the character code convention used to represent data on the external medium. That external character code convention may or may not be the same as the internal native character code convention.

When there is a CODE-SET clause associated with a file,and its alphabet-name-1 specifies a code-set other than the native code-set, then for each record of the file that is read from or written to the external medium a character-by-character translation is done to convert the text of the record according to the mapping specified by alphabet-name-1.

If there is no CODE-SET clause associated with a file,or if there is a CODE-SET clause and its alphabet-name-1 specifies the native code-set, the external character code convention for the file is the same as the internal code convention, and no character translation is done.

A CODE-SET clause for a file may be specified either in the file control entry for the file (as shown in the format), or in the file description entry for the file in the Data Division. It is permissible to specify a CODE-SET clause in both places, but both alphabet-names must be the same.

If the associated file connector is an external file connector, all CODE-SET clauses in the run unit that are associated with that file connector must have the same character set.

In some runtime environments the identity of the code-set associated with a file at the time it is created is preserved with the file as one of its fixed attributes. In such environments it may be a requirement that each time the file is subsequently opened the code-set associated with the file be the same as its original code-set.

COLLATING SEQUENCE Clause

COLLATING SEQUENCE IS alphabet-name-2

The COLLATING SEQUENCE clause may be used to specify a character mapping to be used on the values of the keys of an indexed file before determining their ordering. If no COLLATING SEQUENCE clause is present, the keys are ordered according to the collating sequence implied by the explicitly specified or default code-set of the file. When this clause is used,alphabet-name-2 must have been defined as an alphabet-name in the SPECIAL-NAMES paragraph of the Configuration Section in the Environment Division. The character code set designated by alphabet-name-2 determines the ordering of the keys of the file. Support for a specified collating sequence is system-dependent. On those systems that do not support a specific collating sequence,the native collating sequence is used.

The COLLATING SEQUENCE clause may only be specified in a file control entry that describes an indexed organization file.

In some runtime environments the specification of a COLLATING SEQUENCE clause has no effect. In other runtime environments the identity of the collating sequence associated with a file at the time it is created is preserved with the file as one of its fixed attributes. In such environments it may be a requirement that each time the file is subsequently opened, the collating sequence specified for the file be the same as its original collating sequence.

FILE STATUS Clause

FILE STATUS IS data-name-8

When the FILE STATUS clause is specified, a value will be moved by the runtime system into the data item specified by data-name-8 after the execution of every statement that references the file either explicitly or implicitly. This value indicates the status of execution of the statement. data-name-8 must be defined in the Data Division as a two-character data item of the category alphanumeric and must not be defined in the File Section. data-name-8 may be qualified.The data item referenced by data-name-8 that is updated during the execution of an input-output statement is the one specified in the file control entry associated with that statement. If data-name-8 is specified, is not qualified, and is not defined in the Data Division, the compiler assumes a Working-Storage Section data description entry of the following form:

01 data-name-8 PIC X(2).

LOCK MODE Clause

LOCK MODE IS

LOCK MODE Clause

The LOCK MODE clause specifies whether a file is to be opened in exclusive or shared lock mode and, if shared,the record locking mode. If the LOCK MODE clause is omitted in the file control entry, the file sharing lock mode for the file is determined by options in the OPEN statement, the environment in which the file is opened and a configurable default.The default record locking mode for shared files opened for input-output (open I-O mode) is automatic single.

  • The EXCLUSIVE phrase indicates that all OPEN statements that refer to file-name-1 are to open the file in exclusive mode.
  • The MANUAL phrase indicates that an OPEN statement without the EXCLUSIVE or an applicable WITH LOCK phrase for file-name-1 is to open the file in shared mode and, if the open mode is I-O,in one of the manual record locking modes.
  • The AUTOMATIC phrase indicates that an OPEN statement without the EXCLUSIVE or an applicable WITH LOCK phrase for file-name-1 is to open the file in shared mode and, if the open mode is I-O, in one of the automatic record locking modes.
  • The LOCK ON RECORD phrase specifies one of the single record locking modes. Single record locking modes apply when AUTOMATIC or MANUAL is explicitly stated without the MULTIPLE option.
  • The LOCK ON MULTIPLE RECORDS phrase specifies one of the multiple record locking modes.

If the associated file connector is an external file connector, every file control entry in the run unit that is associated with that file connector must specify the same lock mode.

ORGANIZATION Clause

ORGANIZATION Clause

The ORGANIZATION clause specifies the logical structure of a file. The file organization is established at the time a file is created and cannot subsequently be changed. When the ORGANIZATION clause is not specified, ORGANIZATION IS SEQUENTIAL is implied.

Sequential

Sequential organization is a permanent logical file structure in which a record is identified by a predecessor-successor relationship established when the record is placed into the file.

Sequential files may be further classified by the record delimiting technique used to determine the length of records in the file. The ORGANIZATION clause may specify the record delimiting technique to be binary sequential with the BINARY option or line sequential with the LINE option. For additional information on record delimiting techniques,see the description of the RECORD DELIMITER clause.

Relative

Relative organization is a permanent logical file structure in which each record is uniquely identified by an integer value greater than zero,which specifies the records logical ordinal position in the file.

Indexed

Indexed organization is a permanent logical file structure in which each record is identified by the value of one or more keys within that record. All records are uniquely identified by the value of the prime record key, except when the DUPLICATES phrase is specified in the RECORD KEY clause. Alternate record keys may be defined to provide alternate access paths to records in an indexed file.Record keys may be split keys, which are a concatenation of a sequence of data items that are not necessarily contiguous within the record.

PADDING CHARACTER Clause

PADDING CHARACTER Clause

The PADDING CHARACTER clause provides a way to specify the character that is used to fill out or pad blocks for sequential files.If the padding character is defined with a data-name, data-name-2 may be qualified. It must refer to a one-character data item of the category alphanumeric defined in the Working-Storage or Linkage Section. If the padding character is defined with a literal, literal-2 must be a one-character nonnumeric literal. If data-name-2 is specified, is not qualified, and is not defined in the Data Division, the compiler assumes a Working-Storage Section data description entry of the following form:

PADDING CHARACTER Clause

The PADDING CHARACTER clause may only be specified in a file control entry that describes a sequential organization file.

literal-2 or the value of the data item referenced by data-name-2 at the time the file is opened for output is used as the value of the padding character, and this value becomes a fixed attribute of the file.

During input operations on a file whose file control entry includes a PADDING CHARACTER clause, any portion of a block that exists beyond the last logical record and consists entirely of padding characters is bypassed, and a logical record that consists entirely of padding characters is ignored. During output operations on such a file, any portion of a block that exists beyond the last logical record is filled out with padding characters.

The use and recognition of padding characters occur only if such operations are compatible with the supporting device type.

If the associated file connector is an external file connector, all PADDING CHARACTER clauses in the run unit that are associated with that file connector must have the same specifications. If data-name-2 is specified, it must reference an external data item.

RECORD DELIMITER Clause

RECORD DELIMITER Clause

The RECORD DELIMITER clause specifies the record delimiting technique for a sequential file. The record delimiting technique determines how records are separated on the external medium.An alternative method of specifying the record delimiting technique is the LINE or BINARY option of the ORGANIZATION clause. The record delimiting technique is established at the time a file is created and cannot subsequently be changed.

The RECORD DELIMITER clause may only be specified in a file control en try that describes a sequential organization file.

The RECORD DELIMITER clause with the BINARY-SEQUENTIAL option specifies that the file record delimiting technique is binary sequential. The binary sequential record delimiting technique uses record length headers and trailers to delimit each variable-length record on the external medium. This allows binary sequential files to contain data items with usage other than DISPLAY. For fixed-length binary sequential records, no record delimiter is needed or used. All characters in the records of a binary sequential file are treated as data, not as control characters. When the BINARY-SEQUENTIAL option is specified, the ORGANIZATION clause must not specify the LINE option.

The RECORD DELIMITER clause with the LINE-SEQUENTIAL option specifies that the file record delimiting technique is line sequential. The line sequential record delimiting technique is defined to be the same as that used by the standard system text editor. Typically, this record delimiting technique uses special control characters to delimit each record, for example, a carriage-return line-feed pair. Therefore,such files should contain only data items that are explicitly or implicitly defined with USAGE IS DISPLAY. If there are data items with usage other than DISPLAY in a line sequential file, their values may be interpreted as control characters, for example, record separators or horizontal tabs. When the LINE-SEQUENTIAL option is specified, the ORGANIZATION clause must not specify the BINARY option.

The use of the RECORD DELIMITER clause with the STANDARD-1 option is meaningful only when the supporting external medium is magnetic tape. When this is the case, the clause may be used to indicate that the method of determining the length of a variable record on the external medium is as specified in American National Standard X3.27-1978, Magnetic Tape Labels and File Structure for Information Interchange and International Standard 1001 1979, Magnetic Tape Labels and File Structure for Information Interchange The RECORD DELIMITER clause with the STANDARD-1 option may not be specified if LINE or BINARY is specified in the ORGANIZATION clause since they each specify a different record delimiting technique.

If the RECORD DELIMITER clause is not specified and neither the LINE nor BINARY option is specified in the ORGANIZATION clause, the record delimiting technique for the file is determined by the presence of a Compile Command option or a Runtime Command option.

If the associated file connector is an external file connector, all RECORD DELIMITER clauses in the run unit that are associated with that file connector must have the same specifications.

RECORD KEY and ALTERNATE RECORD KEY Clauses

RECORD KEY and ALTERNATE RECORD KEY Clauses

The RECORD KEY clause specifies the record key that is the prime record key for an indexed file. The values of the prime record key must be unique among records of the file, except when the DUPLICATES phrase is specified in the RECORD KEY clause. This prime record key provides an access path to records in an indexed file. split-key-name-1 names a concatenation of one or more data items within a record associated with the file. The concatenation of the data items, which need not be contiguous within the record, forms a single record key. split-key-name-1 may be specified only in a READ or START statement.

An ALTERNATE RECORD KEY clause specifies a record key that is an alternate record key for an indexed file. This alternate record key provides an alternate access path to records in an indexed file Up to 254 alternate record keys may be declared for an indexed organization file. split-key-name-2 names a concatenation of one or more data items within a record associated with the file. The concatenation of the data items,which need not be contiguous within the record, forms a single record key. split-key-name-2 may be specified only in a READ or START statement.

Note:There is a limit of 255 key segments per indexed file.Thus, if split keys are used, the limit of 254 alternate keys is reduced accordingly.

The RECORD KEY and ALTERNATE RECORD KEY clauses may only be specified in a file control entry that describes an indexed organization file.

The RECORD KEY clause is required in a file control entry that describes an indexed organization file.

If the associated file connector is an external file connector,every file control entry in the run unit that is associated with that file connector must specify the same data description entry for data-name-4, data-name-6 or each data-name-5, data-name-7, the same number of data-name-4, data-name-6 in the definition of split-key-name-1, split-key- name-2, the same relative location within the associated record for data-name-4, data-name-6 or each data-name-5, data-name-7, the same presence or absence of the DUPLICATES phrase, and the same number of alternate record keys.

The data descriptions of data-name-4, data-name-5, data-name-6, and data-name-7, as well as their relative locations within a record, must be the same as those used when the file was created. The number of alternate keys for the file, the sequence of data-name-5 or data-name-7 for each key, and the presence or absence of the DUPLICATES phrase for each key must also be the same as when the file was created.

The data items to which data-name-4, data-name-5, data-name-6, and data-name-7 refer must each be defined within a record description entry associated with file-name-1. Each data item must also be defined either as a category alphanumeric data item or as an unsigned integer data item with DISPLAY usage.

None of data-name-4, data-name-5, data-name-6, and data-name-7 may be described as a data item whose size is variable.

data-name-5 cannot refer to an item whose leftmost character position corresponds to the leftmost character position of an item to which data-name-4 or any other data-name-5 associated with this file refers.split-key-name-2 cannot specify a list of data-names that results in the same key as split-key-name-1 or any other split-key-name-2. Two record keys are considered the same if they have the same relative offset within the record for each key segment, the same length for each key segment and the same number of key segments, where a key segment corresponds to a single data item in the concatenation of data items that form the split key. If split-key-name-2 lists only one data-name-7, then data-name-7 cannot refer to an item whose leftmost character position and length correspond to the leftmost character position and length of an item to which data-name-4 or any data-name-5 associated with this file refers.

data-name-4, data-name-5, data-name-6, and data-name-7 may be qualified.

The DUPLICATES phrase specifies that the value of the associated record key may be duplicated within any of the records in the file. If the DUPLICATES phrase is not specified, the value of the associated record key must not be duplicated among any of the records in the file. When the DUPLICATES phrase is specified in the RECORD KEY clause, the value of the prime record key is not necessarily a unique identifier for a single record; therefore, in this case, the DELETE and REWRITE statements are disallowed in the random access mode and are sequential operations in the dynamic access mode.

Note:The ALTERNATE RECORD KEY clauses may be specified in any order within the file control entry. The compiler sorts the alternate keys into ascending order of offset within the associated record and then ascending length of key segment. For two or more keys with the same offset and length of key segment, the keys are sorted into ascending number of segments. The compiler produces an error if two or more keys are the same, that is, they have the same relative location of each segment, the same length for each segment, and the same number of segments. This sorting of the alternate keys ensures that the associated indexed file description is independent of the order in which ALTERNATE RECORD KEY clauses are specified in the programs that refer to an indexed file.

RESERVE Clause

RESERVE Clause

The RESERVE clause allows the user to specify the number of input-output areas allocated.If the RESERVE clause is specified,the number of input-output areas allocated is equal to the value of integer-1 if the ALTERNATE phrase is omitted or to the value of integer-1 plus one if the ALTERNATE phrase is specified. The maximum number of input-output areas that can be allocated for a file is 255. Therefore, the maximum value that integer-1 can have is 254 when the ALTERNATE phrase is specified, or 255 when the ALTERNATE phrase is not specified.

Specifying RESERVE NO ALTERNATE AREAS is the same as specifying RESERVE 1 AREA. Specifying RESERVE NO AREAS is the same as omitting the RESERVE clause. If the RESERVE clause is not specified,the number of input-output areas allocated defaults to a number appropriate for the runtime operating system.

Sort-Merge File Control Entry

The sort-merge file control entry names a sort or merge file and specifies the association of the file to a storage-medium.

Sort-Merge File Control Entry

SELECT Clause

Each sort or merge file described in the Data Division must be described once and only once as a file-name in the FILE-CONTROL paragraph. Each sort or merge file specified in a file control entry must have a sort-merge file description entry in the Data Division. Since file-name-1 represents a sort or merge file, only the ASSIGN clause is permitted to follow file-name-1 in the FILE-CONTROL paragraph.

ASSIGN Clause

The ASSIGN clause specifies the association of the sort or merge file referenced by file-name-1 to a storage medium (device-name-1), such as SORT, MERGE, SORT-MERGE or SORT-WORK. The device-name may be omitted if a file access name is specified by data-name-1 or literal-1.

The ASSIGN clause may also specify the file access name with literal-1 or as the contents of a data item identified by data-name-1. If specified, the file access name must be correct both syntactically and semantically. However, for a sort-merge file, the value of the file access name is ignored by the object program.

If literal-1 is specified, it must be a nonnumeric literal.

If data-name-1 is specified, it must be defined in the Data Division as a data item of the category alphanumeric. data-name-1 may be qualified. If data-name-1 is specified, is not qualified, and is not defined in the Data Division, the compiler assumes a Working-Storage Section data description entry of the following form:

01 data-name-1 PIC X(256).

I-O-CONTROL Paragraph

I-O-CONTROL Paragraph

The I-O-CONTROL paragraph specifies the points at which rerun is to be established,the memory area which is to be shared by different files, and the location of files on a multiple file reel.

The I-O-CONTROL paragraph is optional. The clauses within the paragraph may appear in any order.

Any file-name referenced in the I-O-CONTROL paragraph must be specified in the FILE-CONTROL paragraph of the same program.

RERUN Clause

RERUN Clause

The RERUN clause specifies when and where the rerun information is recorded. The RERUN clause, when specified, must satisfy the following rules:

  1. file-name-1 must be a sequentially organized file.
  2. The END OF REEL or END OF UNIT phrase may be used only if file-name-2 is a sequentially organized file.
  3. When the END OF REEL or END OF UNIT phrase is used and file-name-2 is not an output file,the ON phrase is required.
  4. When either the integer-1 RECORDS phrase or the integer-2 CLOCK-UNITS phrase is specified,the ON phrase with rerun-name-1 must be specified in the RERUN clause.
  5. When condition-name-1 is used,the ON phrase is required.
  6. Only one RERUN clause containing the CLOCK-UNITS phrase may be specified.
  7. rerun-name-1 may be any user-defined word.

When either the END OF REEL or END OF UNIT phrase is used without the ON phrase, the rerun information is written on file-name-2, which must be an output file. When either the END OF REEL or END OF UNIT phrase is used and file-name-1 is specified in the ON phrase, the rerun information is written onfile-name-1, which must be an output file. In this case, file-name-2 may be either an input or output file.

When the integer-1 RECORDS phrase is used, the rerun information is written whenever integer-1 records of file-name-2 have been processed.file-name-2 may be either an input or output file with any organization or access.

When the integer-2 CLOCK-UNITS phrase is used, the rerun information is written whenever an interval of time, calculated by an internal clock, has elapsed.

When condition-name is used and file-name-1 is specified in the ON phrase, the rerun information is written on file-name-1, which must be an output file, whenever a switch assumes a particular status as specified by the condition-name-1. The associated switch must be defined in the SPECIAL-NAMES paragraph.

More than one RERUN clause may be specified for a given file-name-2, provided that:

  • When multiple integer-1 RECORDS phrases are specified, no two of them may specify the same file-name-2.
  • When multiple END OF REEL or END OF UNIT phrases are specified, no two of them may specify the same file-name-2.

SAME Clause

SAME Clause

In the SAME clause, SORT and SORT-MERGE are equivalent.

If the SAME SORT AREA or SAME SORT-MERGE AREA clause is used, at least one of the file-names must represent a sort or merge file. Files that do not represent sort or merge files may also be named in the clause.

The file-names specified in a SAME clause may not reference an external file connector.

The four formats of the SAME clause (SAME AREA, SAME RECORD AREA, SAME SORT AREA,SAME SORT-MERGE AREA) are considered separately in the following.

More than one SAME clause may be included in a program. The following restrictions apply:

  1. A file-name must not appear in more than one SAME AREA clause.
  2. A file-name must not appear in more than one SAME RECORD AREA clause.
  3. A file-name which represents a sort or merge file must not appear in more than one SAME SORT AREA or SAME SORT-MERGE AREA clause.
  4. If one or more file-names of a SAME AREA clause appear in a SAME RECORD AREA clause, all the file-names in that SAME AREA clause must appear in the SAME RECORD AREA clause. However, additional file-names not appearing in that SAME AREA clause may also appear in that SAME RECORD AREA clause. The rule that only one of the files mentioned in a SAME AREA clause can be open at any given time takes precedence over the rule that all files mentioned in a SAME RECORD AREA clause can be open at any given time.
  5. If a file-name that does not represent a sort or merge file appears in a SAME AREA clause and one or more SAME SORT AREA or SAME SORT-MERGE AREA clauses, all of the files named in that SAME AREA clause must be named in that SAME SORT AREA or SAME SORT-MERGE area clause.

The files referenced in the SAME AREA, SAME RECORD AREA, SAME SORT AREA, or SAME SORT-MERGE AREA clause need not all have the same organization or access.

The SAME AREA clause specifies that two or more files that do not represent sort or merge files are to use the same memory area during processing. The area being shared includes all storage areas assigned to the files specified; therefore,it is not valid to have more than one of the files open at the same time.

The SAME RECORD AREA clause specifies that two or more files are to use the same memory area for processing of the current logical record.All of the files may be open at the same time. A logical record in the SAME RECORD AREA is considered a logical record of each opened output file whose file-name appears in this SAME RECORD AREA clause and of the most recently read input file whose file-name appears in this SAME RECORD AREA clause. This is equivalent to an implicit redefinition of the area (that is, records are aligned on the leftmost character position).

If the SAME SORT AREA or SAME SORT-MERGE AREA clause is used, at least one of the file-names must represent a sort or merge file. Files that do not represent sort or merge files may also be named in the clause. This clause specifies that storage is shared as follows:

  1. The SAME SORT AREA or SAME SORT-MERGE AREA clause specifies a memory area which will be made available for use in sorting or merging each sort or merge file named. Thus any memory area allocated for the sorting or merging of a sort or merge file is available for reuse in sorting or merging any of the other sort or merge files.
  2. In addition, storage areas assigned to files that do not represent sort or merge files may be allocated as needed for sorting or merging the sort or merge files named in the SAME SORT AREA or SAME SORT-MERGE AREA clause. In this implementation,no such sharing occurs during execution.
  3. Files other than sort or merge files do not share the same storage area with each other. Users wishing these files to share the same storage area with each other must also include in the program a SAME AREA or SAME RECORD AREA clause naming these files.
  4. During the execution of a SORT or MERGE statement that refers to a sort or merge file named in this clause, any non sort-merge files named in this clause must not be open.

MULTIPLE FILE Clause

MULTIPLE FILE TAPE CONTAINS

MULTIPLE FILE Clause

The MULTIPLE FILE clause is required when more than one file shares the same physical reel of tape and the operating system does not specify file positions. Regardless of the number of files on a single reel, only those files that are used in the object program need be specified. If all file-names have been listed in consecutive order,the POSITION clause need not be given.

If any file in the sequence is not listed, the position one-relative to the beginning of the tape must be specified in the POSITION clause. Whenever the POSITION clause is omitted, the position is assumed to be one greater than the position of the immediately preceding file in the MULTIPLE FILE clause, except for the first file-name-5, which is assumed to be in position 1 when the POSITION clause is omitted.

The file-names specified in a MULTIPLE FILE clause may not reference an external file connector.

Not more than one file on the same tape reel may be open at one time.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

COBOL Topics