CIS314 COBOL STATEMENTS FOR FILE INPUT AND OUTPUT

 

FILE – made up of records

RECORD – made up of fields

FIELD – piece of a record

 

 

SELECT file-name ASSIGN TO “………….”  ORGANIZATION IS LINE SEQUENTIAL 

            where  file-name is a user created data name

where  ORGANIZATION IS LINE SEQUENTIAL is used for input files that have one record per line

where  this statement exists in the ENVIRONMENT DIVISION, INPUT-OUTPUT SECTION, FILE-CONTROL paragraph

 

FD  file-name.

01   record-name…

            where  FD stands for File Description

where  this statement exists in the DATA DIVISION, FILE SECTION (not working-storage section)

where  file-name matches the file-name on the SELECT

 

OPEN mode file-name

            where mode is INPUT or OUTPUT

            where file-name matches the file-name on a SELECT and FD

           

READ file-name [INTO data-name]

              AT END

                  do something

END-READ

 

WRITE record-name

              [FROM data-name]

              AFTER|BEFORE

              ADVANCING

              PAGE|value LINES

 

CLOSE filename

 

******************************************************************************