Cobol-How to Code Relative Files?

A relative file consists of a specified number of areas. Each of these areas can contain a record, or it can be empty.

To identify an area in a relative file, you use a relative record number that indicates the area’s relative position in the file.

Select statement looks like this:

Image from book

system-name is equal to DD name.

In the Select statement we write as:

SELECT INVMAST  ASSIGN TO INVMAST
                ORGANIZATION IS RELATIVE
                ACCESS IS SEQUENTIAL/RANDOM
                RELATIVE KEY IS INVMAST-RR-NUMBER.

We can open the files:

Image from book

Start the record:

Image from book

Delete the record:

DELETE file-name RECORD
    [INVALID KEY imperative-statement-1]
    [NOT INVALID KEY imperative-statement-2]
    [END-DELETE]

Closing file name:

CLOSE file-name.

Read/Write/Re-write I will give about these in my next post.

About these ads