section11 - ex: DATA DIVISION FILE SECTION. FD...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Business Oriented Programming February 3, 2005 Course 92-252-01 – Spring 2005 Accessing Files. We will try this in class today together as we talk about what is required by COBOL. COBOL Programs using files must list information in the: ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL Paragraph. In FILE-CONTROL we tell COBOL where to find our data file. We link the file name within our operating system to the file name within the program code. EX:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL Paragraph SELECT (PROGRAM-FILENAME) ASSIGN TO (“OPERATING SYSTEM FILENAME”). Then in DATA DIVISION, we have to describe the layout of the file. We use the same PROGRAM- FILENAME from above. This links the environment section to the layout of the file. We also need to tell the program the various fields that are contained on each record in the file.
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ex: DATA DIVISION FILE SECTION. FD PROGRAM-FILENAME. 01 RECORDNAME. 02 FIELD PIC X(3) We need to open the file before we can read any records. ex: OPEN PROGRAM-FILENAME. We need to read from the file to load the buffer and we need to control the end of file situation COBOL only does what we tell it to do. SO, We include the 88 field in our record layout. ex: ex: DATA DIVISION FILE SECTION. FD PROGRAM-FILENAME. 02 RECORDNAME. 88 ENDOFFILE value HIGH-VALUES. 02 FIELD PIC X(3) ex: READ PROGRAM-FILENAME at end set ENDOFFILE TO TRUE. We process all records until ENDOFFILE is TRUE. PERFORM UNTIL ENDOFFILE STATEMENT STATEMENT READ StudentFile AT END SET EndOfStudentFile TO TRUE We need to CLOSE the file after the program is done or the operating system will not let us use the file. ex: CLOSE PROGRAM-FILENAME....
View Full Document

Page1 / 5

section11 - ex: DATA DIVISION FILE SECTION. FD...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online