File systems

Record-oriented files that have sequential, relative, indexed, or line-sequential organization are accessed through a file system.

COBOL for Linux® supports the following file systems for sequential, relative, and indexed files:
Db2® (Db2 relational database) file system
Lets batch COBOL programs create and access CICS® files that are stored in Db2.
SdU (SMARTdata Utilities) file system
Files in the SdU file system can be shared with PL/I programs.
SFS (CICS Structured File Server) file system
One of the file systems used by CICS. CICS SFS is supplied as part of CICS. SFS files can be shared with PL/I programs.
STL (standard language) file system
Provides the basic facilities for local files.
COBOL for Linux supports the following file systems for sequential files:
QSAM (queued sequential access method) file system
Lets COBOL programs access QSAM files that are transferred from the mainframe to Linux using FTP.
RSD (record sequential delimited) file system
Lets COBOL programs share data with programs written in other languages. RSD files are sequential only, with fixed or variable-length records, and support all COBOL data types in records. Text data in records can be edited by most file editors.

You can specify the file system for a given sequential, relative, or indexed file in any of several ways. For details, see the related reference about precedence of file-system determination.

Record-oriented files that have line-sequential organization can be accessed only through the LSQ (line sequential) file system.

Db2 files are managed by the DB2 command-line utility; SFS files are managed by the sfsadmin command-line utility. All other files exist in the line sequential Linux file system, and are managed by standard Linux commands such as cp, ls, mv, and rm. (Do not however use the cp or mv command for SdU files, which consist of multiple component files that refer to one another internally.)

All the file systems let you use COBOL statements to read and write COBOL files. Most programs have the same behaviors in all file systems. However, files written using one file system cannot be read using a different file system.

To associate a COBOL file name to a file system and operating system file name, use one of the following three methods that are listed in increasing order of flexibility, where RSD is used as an example file system:
  • Code ASSIGN TO RSD-assignment-name in your program.
  • Set the following environment variable: export COBRTOPT=FS=RSD:.
  • Set the following command: export assignment-name=RSD-os-file-name.
It is common for a COBOL program to use multiple file systems during the execution; for example:
  • Use the RSD file system for transaction files that are used to update the database file.
  • Use the STL file system for indexed or relative database files.
  • Use the RSD file system for output files.
  • All other files exist in the native Linux file system.
Tip: To avoid changing and recompiling COBOL programs when the file system changes, you can use environment variables to associate a file system, and file name with the ASSIGN clause rather than use the COBRTOPT default settings.

Related concepts  
Line-sequential file organization