Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

SAME AREA clause

Function

The SAME AREA clause indicates that a number of files are to share a specified input/output area during program execution.

Format 1

applies to all files except sort files, unless RECORD is specified

Format 2

is suitable for sort files

Format 1 for all types of file organization


SAME [RECORD] AREA FOR file-name-1 {file-name-2}...


Syntax rules

  1. More than one SAME AREA clause may be included in a program. In this case, the following must be observed:

    A specific file-name must not appear in more than one SAME AREA clause. The same is true of the SAME RECORD AREA clause.

    A specific file-name may concurrently appear in a SAME RECORD AREA clause. In this case, all file-names appearing in the SAME AREA clause must also appear in the SAME RECORD AREA clause. The SAME RECORD AREA clause may also contain other file-names that do not appear in the SAME AREA clause.

  2. The SAME AREA clause indicates that the specified files (no sort-files) are to share the input/output areas assigned to them.

  3. The SAME RECORD AREA clause indicates that the specified files are to share the same storage areas for processing the current logical record.

    A logical record in the SAME RECORD AREA clause is considered a logical record of all files which are opened for OUTPUT and whose names are supplied in that SAME RECORD AREA clause. It is also a logical record of the file (in this clause) from which the most recent input occurred. This is equivalent to an implicit overwriting of all record areas, where the records are aligned on the leftmost character position.

  4. file-name-1 and file-name-2 may not be files with organization XML.

General rules

  1. If SAME AREA is used, only one file may be open at any given time.

  2. If the RECORD phrase is used, all specified files may be open at the same time.

  3. General rule 1 applies in the case of files that are specified in the SAME AREA clause as well as the SAME RECORD AREA clause.

  4. The SAME [RECORD] AREA clause must not be specified for external files.

Format 2 for sorting records


SAME {RECORDSORTSORT-MERGE} AREA FOR file-name-1 {file-name-2}...


Syntax rules

  1. SORT and SORT-MERGE are equivalent.

  2. If SAME SORT AREA or SAME SORT-MERGE AREA is used, at least one of the filenames must refer to a sort or merge file. Files which are not sort or merge files may also be specified in the clause.

  3. More than one SAME AREA clause may appear in a given program, but the following restrictions must be observed:

    1. A given file-name must not occur in more than one SAME RECORD AREA clause.

    2. A file-name representing a sort-file must not appear in more than one SAME SORT AREA or SAME SORT-MERGE AREA clause.

    3. If a file-name which does not represent a sort-file appears in a SAME AREA clause and in one (or more) SAME SORT AREA or SAME SORT-MERGE AREA clause(s), then all files specified in the SAME AREA clause must also be supplied in the SAME SORT AREA or SAME SORT-MERGE AREA clause.

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

  5. file-name-1 and file-name-2 may not be files with organization XML.

General rule

  1. The SAME RECORD AREA clause indicates that two or more files should share the storage area in which the current logical record is being processed. All of the files can be open at the same time. A logical record in the "same record area" is considered as a logical record of each opened output file whose file-name occurs in the SAME RECORD AREA clause; it is also considered as a logical record of the last read input file whose file-name occurs in the SAME RECORD AREA clause. This is equivalent to an implicit redefinition of the internal storage area, where the records are aligned on the leftmost character position.