ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PERSON-FILE
ASSIGN TO 'C:\PCOBWIN\ROGERS\I\PERSON.DAT'
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS PERSON-KEY
ALTERNATE RECORD KEY IS PERSON-ALTERNATE-KEY
WITH DUPLICATES
FILE STATUS IS IO-FILE-STATUS.
DATA DIVISION.
FILE SECTION.
FD PERSON-FILE
DATA RECORD IS PERSON-ITEM.
01 PERSON-ITEM.
02 PERSON-KEY.
03 PERSON-ID PICTURE X(4).
02 PERSON-ALTERNATE-KEY.
03 PERSON-NAME PICTURE X(20).
02 PERSON-ADDRESS PICTURE X(20).
02 PERSON-CITY PICTURE X(18).
02 PERSON-STATE PICTURE X(2).
02 PERSON-ZIP PICTURE X(5).
02 PERSON-PHONE.
03 PERSON-AREA-CODE PICTURE X(3).
03 PERSON-PHONE-NUMBER PICTURE X(7).
02 PERSON-STATUS PICTURE X.
WORKING-STORAGE SECTION.
01 KBD-LETTER PIC X.
01 INVALID-PERSON-KEY-FLAG PICTURE X.
88 INVALID-PERSON-KEY VALUE 'Y'.
88 VALID-PERSON-KEY VALUE 'N'.
01 IO-FILE-STATUS PICTURE X(2).
PROCEDURE DIVISION.
MAIN-LINE.
PERFORM INITIALIZATION-ROUTINE.
PERFORM THE-LOOP
UNTIL INVALID-PERSON-KEY.
PERFORM EOJ-ROUTINE.
STOP RUN.
INITIALIZATION-ROUTINE.
OPEN I-O PERSON-FILE.
PERFORM GET-NEXT-PERSON-ITEM.
THE-LOOP.
DISPLAY PERSON-NAME.
DISPLAY PERSON-ADDRESS.
DISPLAY PERSON-CITY ' ' PERSON-STATE ' ' PERSON-ZIP.
DISPLAY '(' PERSON-AREA-CODE ') '
PERSON-PHONE-NUMBER (1:3) '-'
PERSON-PHONE-NUMBER (4:4).
DISPLAY '------------------------------'.
PERFORM GET-NEXT-PERSON-ITEM.
EOJ-ROUTINE.
CLOSE PERSON-FILE.
GET-NEXT-PERSON-ITEM.
MOVE 'N' TO INVALID-PERSON-KEY-FLAG.
READ PERSON-FILE NEXT
AT END
MOVE 'Y' TO INVALID-PERSON-KEY-FLAG.