RECORDING MODE Clause
The RECORDING MODE clause and the BLOCK CONTAINS clause are used in the FILE-CONTROL paragraph of the COBOL program to specify the record and block format of a file.
The RECORDING MODE clause is used to specify the type of record format that is used in a file.
Syntax:
RECORDING MODE IS {F | V | U}
Where “F” stands for Fixed, “V” stands for Variable and “U” stands for undefined.
- Fixed-length records: The record length is fixed and does not change.
- Variable-length records: The record length can change, and there is no maximum length defined.
- Undefined-length records: the record length is not defined.
BLOCK Clause :
The BLOCK CONTAINS clause is used to specify the block size of a file.
Syntax:
BLOCK CONTAINS integer [RECORD] [TO integer] [RECORD]
where “integer” is the number of records in the block and “TO integer” is used to specify the maximum number of records. The optional “RECORD” keyword is used to specify that the block size is in terms of records.
DATA RECORD:
The DATA RECORD is a Data Division item that describes the layout of the records in a file.
Syntax:
DATA RECORD IS record-name.
Where “record-name” is the name of the record in the Data Division that contains the layout of the records in the file.
Here’s an example of how the RECORDING MODE, BLOCK CONTAINS, and DATA RECORD clauses could be used in a COBOL program:
Cobol
FD CUSTOMER- FILE RECORDING MODE IS F BLOCK CONTAINS 10 RECORD DATA RECORD IS CUSTOMER- RECORD . |
This example defines a file called “CUSTOMER-FILE” with a fixed-length record format, a block format that contains 10 records and the layout of the records is defined in the “CUSTOMER-RECORD” Data Division item
It’s worth noting that the use of these clauses may vary depending on the specific COBOL implementation and platform being used.
File Section in COBOL
COBOL is a high-level programming language for business applications or business use. It was designed in 1959 by the Conference on Data Systems Language (CODASYL). It was primarily used in business, finance, and administration system for companies and governments. COBOL is still widely used in application deployment on mainframe computers.
File Selection
In COBOL, file selection is the process of identifying which records in a file should be processed or read. This is typically done using the SELECT and ASSIGN clauses in the FILE-CONTROL paragraph of the COBOL program.
The SELECT clause is used to specify the file that will be used in the program, and the ASSIGN clause is used to specify the device or file name where the file is stored.
For example, to select a file called “CUSTOMER” that is stored on a magnetic tape, the following code could be used:
Cobol
SELECT CUSTOMER- FILE ASSIGN TO TAPE |
Additionally, the COBOL program can use the READ statement and a conditional statement to read only the records that meet certain conditions and skip the rest of the records.
For example, to read only the records of customers with a balance greater than zero:
Cobol
READ CUSTOMER- FILE INTO CUSTOMER- RECORD IF CUSTOMER- RECORD -BALANCE > 0 PERFORM PROCESS -CUSTOMER |
Note: The file selection and reading methods may vary depending on the specific COBOL implementation and platform being used.