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

Have Something to Say? Post Your Comment

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s