File concatenation
COBOL for Linux® supports assignment of a concatenation of files to an internal file (file-name-1 in the SELECT clause). The file concatenation is specified by multiple file identifiers that are separated by colons (:).
- file-system-ID
- The file system in which system-file-name exists if file-system-ID consists of at least three alphanumeric characters, and the first character is alphabetic. Otherwise, the entire file identifier is interpreted as the name of the file in the default file system.
- system-file-name
- The name of the file in the specified file system if file-system-ID is specified; otherwise, the entire file identifier is interpreted as the name of the file in the default file system. system-file-name can include the drive and path information for the file.
For example:
export MYFILE='STL-/home/user1/file1:STL-/home/user1/file2'
In this example, MYFILE
is the result
of the file concatenation of /home/user1/file1
and /home/user1/file2
,
both in the STL file system.
A file identifier cannot contain a colon (:) because the file identifier would then be interpreted as a concatenation of two separate files.
Up to 256 file identifiers can be specified in a concatenation. File identifiers need not be unique. For example, a concatenation can consist of 256 occurrences of the same file identifier. Adjacent colons are treated as a single colon.
File concatenation is supported for the environment variable value, the ASSIGN USING data item content, and the literal form of the assignment name.
- FILE ORGANIZATION is SEQUENTIAL or LINE SEQUENTIAL.
- ACCESS MODE is SEQUENTIAL.
- The mode of any OPEN statements is INPUT.
These criteria are checked at run time, even if the concatenation is specified in the literal form of the assignment name.
If a colon precedes or follows a single file identifier, the file becomes a member of a trivial concatenation, and is read-only in any programs that use the file, regardless of its file permissions.
Concatenation is supported for all file systems. The file-system ID can be specified on any or all of the file identifiers in a given concatenation. However, all file identifiers in a concatenation must specify or default to the same file system at run time, and the files must have consistent attributes.
A concatenation can include individual generation files or entire generation data groups (GDGs). If a GDG is specified as a member of a concatenation, the individual files in the group are read in generation order, that is, from the most current generation to the oldest generation. For more information about generation data groups or generation files, see Generation data groups in the COBOL for Linux on x86 Programming Guide.
A concatenation can also include empty files, that is, files that contain no records. When empty files are read, they immediately return end-of-file internally, and are thus invisible to the program that reads the concatenated files. If the concatenation contains only empty files, the first READ operation returns end-of-file, and the AT END condition exists.
If a COBOL file is defined with the OPTIONAL phrase in a SELECT clause, the concatenation can include unavailable files. A file is unavailable if it does not exist or the file permissions do not allow the requested operation. An unavailable file is treated like an empty file, thus is invisible to the program.
For more information about concatenating files, see Concatenating files in the COBOL for Linux on x86 Programming Guide.