IDENTIFICATION DIVISION.
PROGRAM-ID. TABLE-DEMO.
AUTHOR. Kevin Roper.
INSTALLATION. KEYHOLE HQ.
DATE-WRITTEN. 05/15/20.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PEOPLEFILE ASSIGN TO './PEOPLE.ONELINE.DATA'
ORGANIZATION IS SEQUENTIAL.

DATA DIVISION.

FILE SECTION.
FD PEOPLEFILE.
01 PERSON-RECORD.
  02 PERSON-FILE-DATA PIC X(108).

WORKING-STORAGE SECTION.
01 DEMO-EOF PIC A(1) VALUE IS 'N'.
01 DVDR     PIC X(8) VALUE IS "--------".

01 USER-VAL PIC X(10).

01 PEOPLE.
  02 PERSON OCCURS 10 TIMES INDEXED BY PERSON-INDEX.
       05 PERSON-ID PIC X(3).
       05 PERSON-DATA OCCURS 3 TIMES INDEXED BY DATA-INDEX.
           10 PERSON-DATUM PIC X(10).

PROCEDURE DIVISION.
DISPLAY 'Table Demo'.
MOVE '001KEVINDATAK002JACOBDATAJ' TO PEOPLE.

PERFORM GET-NAME.

OPEN INPUT PEOPLEFILE.
 PERFORM UNTIL DEMO-EOF='Y'
  READ PEOPLEFILE INTO PERSON-RECORD
  AT END MOVE 'Y' TO DEMO-EOF
  END-READ
  END-PERFORM.
CLOSE PEOPLEFILE.
*>DISPLAY PERSON-RECORD.
MOVE PERSON-RECORD TO PEOPLE.

*>PERFORM DISPLAY-PERSON UNTIL PERSON-INDEX>3.
MOVE 1 TO PERSON-INDEX.
PERFORM DISPLAY-PERSON-B UNTIL PERSON-INDEX>3.

MOVE 1 TO PERSON-INDEX.
MOVE 1 TO DATA-INDEX.
SEARCH PERSON
  AT END DISPLAY 'NOT FOUND'
  WHEN PERSON-DATUM(PERSON-INDEX,DATA-INDEX)='9993334444'
  DISPLAY 'FOUND KIRK'
  PERFORM DISPLAY-PERSON-B
  END-SEARCH.

STOP RUN.

DISPLAY-PERSON.
DISPLAY PERSON-ID(PERSON-INDEX).
DISPLAY PERSON-DATUM(PERSON-INDEX,1).
DISPLAY PERSON-DATUM(PERSON-INDEX,2).
DISPLAY PERSON-DATUM(PERSON-INDEX,3).
DISPLAY DVDR.
SET PERSON-INDEX UP BY 1.

DISPLAY-PERSON-B.
DISPLAY PERSON-ID(PERSON-INDEX) ':' PERSON-DATUM(PERSON-INDEX,1) ' ' PERSON-DATUM(PERSON-INDEX,2) ' ' PERSON-DATUM(PERSON-INDEX,3).
DISPLAY DVDR.
SET PERSON-INDEX UP BY 1.

GET-NAME.
DISPLAY 'WHAT IS YOUR NAME?'.
ACCEPT USER-VAL.
DISPLAY 'HELLO ' USER-VAL.
DISPLAY ' '.
