SAME RECORD AREA Clause

The SAME RECORD AREA clause specifies that two or more files are to use the same main storage area for processing the current logical record. All of the files may be open at the same time.
Note: The SAME RECORD AREA clause is intended to make efficient use of main storage. However, IBM® i virtual storage architecture eliminates the need for this clause, and the clause is supported for compatibility rather than for performance. Use of the SAME RECORD AREA clause actually degrades performance and increases program size.

SAME RECORD AREA Clause - Format

Read syntax diagramSkip visual syntax diagramSAMERECORDAREAFORfile-name-3file-name-4
A logical record in the shared storage area is considered to be both of the following:
  • A logical record of each opened output file using the SAME RECORD AREA clause
  • A logical record of the most recently read input file using the SAME RECORD AREA clause.

The SAME RECORD AREA clause allows transfer of data from one file to another with no explicit data manipulation because the input/output record areas of named files are identical, and all are available to the user.

More than one SAME RECORD AREA clause may be included in a program. However:
  • A specific file-name must not appear in more than one SAME RECORD AREA clause.
  • 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 that SAME RECORD AREA clause. However, the SAME RECORD AREA clause may contain additional file-names that do not appear in the SAME AREA clause.
  • If the SAME RECORD AREA is specified for several files, the record description entries or the file description entries for these files must not include the GLOBAL clause.
  • The SAME RECORD AREA clause cannot be used with EXTERNAL files.