Tuesday, 12 August 2014

Everything You Need To Know About COBOL READ STATEMENT, COBOL Read INTO.


COBOL READ Statement.

In today's tutorial, you will learn how to read data from files using COBOL programs. Also, you'll learn the implementation of the COBOL READ statement and its different variants. You’ll also learn how to update and maintain the records in sequential files. So, without wasting any more time let's continue with the tutorial.

As you all know that file handling is one of the most important features of COBOL. In the various business application, million of COBOL program READ, UPDATE, DELETE or ALTER data stored in the files. In almost all applications whether mainframe or non-mainframe files are used to store data for daily processings.

How to read a file in COBOL?

COBOL READ statement is used to read data from the file, but before issuing a read command you need to open the file in the desired mode for example If you just want to read records from the file then you need to open the file in input mode but if you want to read and update the transaction record in the file, you can open the file in I-O (i.e. input-output) mode.

The primary function of the COBOL READ statement is to fetch data from the file and move it to the working storage area that was specified while defining the file definition. This is equivalent to a Read statement followed by a Move statement.


The READ statement in COBOL.
COBOL READ INTO
COBOL READ STATEMENT.

The READ statement in COBOL can be also used with an AT END and NOT AT END clauses. The AT END clause determines whether there is any more input and the programmer can decide what to do based on the answer. The NOT AT END can be used to accomplish specific tasks when an AT END has not been reached.

The Read statement reads the next record into the record area for the file. If the Into clause is included, the record is then moved to the specified area in working storage.

Example: COBOL program to read a file an write to another file.

COBOL READ Statement

No comments:

Post a Comment

New In-feed ads