IDENTIFICATION DIVISION.
       PROGRAM-ID.  SCRMENU.
       AUTHOR.  GROCER.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       SELECT VSAM-FILE
           ASSIGN TO "C:\PCOBWIN\SCREENS\VSAMPROJ.DAT"
           ORGANIZATION IS INDEXED
           ACCESS IS DYNAMIC
           RECORD KEY IS VSAM-STUDENT-ID
           ALTERNATE RECORD KEY IS
               VSAM-STUDENT-NAME WITH DUPLICATES.
       SELECT PRINT-FILE ASSIGN TO PRINTER.
       DATA DIVISION.
       FILE SECTION.
       FD  VSAM-FILE
           DATA RECORD IS VSAM-REC.
       01  VSAM-REC.
           05  VSAM-STUDENT-ID          PIC XXXX.
           05  VSAM-STUDENT-NAME        PIC X(20).
           05  VSAM-STUDENT-MAJOR       PIC XXX.
           05  VSAM-STUDENT-SEM-ENTER   PIC X.
           05  VSAM-STUDENT-YR-ENTER    PIC 9999.
       FD  PRINT-FILE
           DATA RECORD IS PRINTZ.
       01  PRINTZ.
           05  FILLER                      PIC X.
           05  VSAM-STUDENT-ID-PR          PIC X(4).
           05  FILLER                      PIC X(2).
           05  VSAM-STUDENT-NAME-PR        PIC X(20).
           05  FILLER                      PIC X(2).
           05  VSAM-STUDENT-MAJOR-PR       PIC XXX.
           05  FILLER                      PIC X(2).
           05  VSAM-STUDENT-SEM-ENTER-PR   PIC X.
           05  FILLER                      PIC X(2).
           05  VSAM-STUDENT-YR-ENTER-PR    PIC 9999.
           05  FILLER                      PIC X(2).
           05  PROCESSING-MSG-PR           PIC X(20).
           05  FILLER                      PIC X(18).
       WORKING-STORAGE SECTION.
       01  INDICATORS.
           05  EOF-IND          PIC XXX          VALUE "NO ".
       01  HOLD-AREAS.
           05  MENU-ANS            PIC X            VALUE SPACES.
               88  VALID-MENU-ANS     VALUE "M", "S", "Y", "T".
           05  RETRIEVE-ANS        PIC X            VALUE SPACES.
           05  ID-ANS              PIC XXXX         VALUE SPACES.
           05  NAME-ANS            PIC X(20)        VALUE SPACES.
           05  RESPONSE-ID-ANS     PIC X            VALUE SPACES.
           05  RESPONSE-NAME-ANS   PIC X            VALUE SPACES.
           05  CHANGE-MAJOR-ANS    PIC X            VALUE SPACES.
           05  CHANGE-SEMESTER-ANS PIC X            VALUE SPACES.
           05  CHANGE-YEAR-ANS     PIC X            VALUE SPACES.
           05  ANY-KEY-ERR-ANS     PIC X            VALUE SPACES.
           05  REC-PROCESSED       PIC XXX          VALUE "NO ".
           05  MSG-TO-DISPLAY      PIC X(40)        VALUE SPACES.
       SCREEN SECTION.
       01  MENU-SCREEN.
           05  VALUE "MENU SCREEN"               BLANK SCREEN
                                                 LINE 02 COL 20.
           05  VALUE "M - CHANGE MAJOR"          LINE 04 COL 05.
           05  VALUE "S - CHANGE SEMESTER"       LINE 06 COL 05.
           05  VALUE "Y - CHANGE YEAR"           LINE 08 COL 05.
           05  VALUE "T - TERMINATE PROCESSING"  LINE 10 COL 05.
           05  VALUE "ENTER CHOICE:"             LINE 17 COL 10.
           05  MENU-ANS-SCR                      LINE 17 COL 25
                      PIC X        TO MENU-ANS.
       01  ENTER-ID-RANDOMLY-SCREEN.
           05  VALUE "RETRIEVE A RECORD BY IDENTIFICATION NUMBER"
                                                 BLANK SCREEN
                                                 LINE 02 COL 15.
           05  VALUE "ENTER THE ID TO RETRIEVE:" LINE 05 COL 05.
           05  ENTRY-PT-SCR                      LINE 05 COL 35
                   PIC XXXX   TO ID-ANS.
           05  VALUE "P - TO PROCESS"            LINE 10 COL 20.
           05  VALUE "C - TO CANCEL"             LINE 11 COL 20.
           05  VALUE "Q - TO QUIT"               LINE 12 COL 20.
           05  VALUE "ENTER CHOICE:"             LINE 14 COL 20.
           05  RESPONSE-ANS-SCR                  LINE 14 COL 35
                   PIC X      TO RESPONSE-ID-ANS.
       01  CHANGE-MAJOR-SCREEN.
           05  VALUE "CHANGE MAJOR"              BLANK SCREEN
                                                 LINE 02 COL 20.
           05  VALUE "ID #:"                     LINE 04 COL 05.
           05  ID-SCR                            LINE 04 COL 15
                      PIC XXXX  FROM VSAM-STUDENT-ID.
           05  VALUE "NAME:"                     LINE 06 COL 05.
           05  NAME-SCR                          LINE 06 COL 15
                      PIC X(20) FROM VSAM-STUDENT-NAME.
           05  VALUE "MAJOR:"                    LINE 08 COL 05.
           05  MAJOR-SCR                         LINE 08 COL 15
                      PIC XXX   USING VSAM-STUDENT-MAJOR.
           05  VALUE "ENTRANCE:"                 LINE 10 COL 05.
           05  VALUE "SEMESTER:"                 LINE 11 COL 10.
           05  SEM-SCR                           LINE 11 COL 20
                      PIC X     FROM VSAM-STUDENT-SEM-ENTER.
           05  VALUE "YEAR:"                     LINE 11 COL 23.
           05  YEAR-SCR                          LINE 11 COL 30
                      PIC 9999  FROM VSAM-STUDENT-YR-ENTER.
           05  VALUE "P - PROCESS CHANGES"       LINE 13 COL 05.
           05  VALUE "C - CANCEL - CHANGES WILL NOT BE MADE"
                                                 LINE 14 COL 05.
           05  VALUE "RESPONSE:"                 LINE 16 COL 30.
           05  CHANGE-MAJOR-SCR                  LINE 16 COL 40
                      PIC X     TO CHANGE-MAJOR-ANS.
       01  CHANGE-SEMESTER-SCREEN.
           05  VALUE "CHANGE SEMESTER"           BLANK SCREEN
                                                 LINE 02 COL 20.
           05  VALUE "ID #:"                     LINE 04 COL 05.
           05  ID-SCR                            LINE 04 COL 15
                      PIC XXXX  FROM VSAM-STUDENT-ID.
           05  VALUE "NAME:"                     LINE 06 COL 05.
           05  NAME-SCR                          LINE 06 COL 15
                      PIC X(20) FROM VSAM-STUDENT-NAME.
           05  VALUE "MAJOR:"                    LINE 08 COL 05.
           05  MAJOR-SCR                         LINE 08 COL 15
                      PIC XXX   FROM VSAM-STUDENT-MAJOR.
           05  VALUE "ENTRANCE:"                 LINE 10 COL 05.
           05  VALUE "SEMESTER:"                 LINE 11 COL 10.
           05  SEM-SCR                           LINE 11 COL 20
                      PIC X     USING VSAM-STUDENT-SEM-ENTER.
           05  VALUE "YEAR:"                     LINE 11 COL 23.
           05  YEAR-SCR                          LINE 11 COL 30
                      PIC 9999  FROM VSAM-STUDENT-YR-ENTER.
           05  VALUE "P - PROCESS CHANGES"       LINE 13 COL 05.
           05  VALUE "C - CANCEL - CHANGES WILL NOT BE MADE"
                                                 LINE 14 COL 05.
           05  VALUE "RESPONSE:"                 LINE 16 COL 30.
           05  CHANGE-SEMESTER-SCR               LINE 16 COL 40
                      PIC X     TO CHANGE-SEMESTER-ANS.
       01  CHANGE-YEAR-SCREEN.
           05  VALUE "CHANGE YEAR"               BLANK SCREEN
                                                 LINE 02 COL 20.
           05  VALUE "ID #:"                     LINE 04 COL 05.
           05  ID-SCR                            LINE 04 COL 15
                      PIC XXXX  FROM VSAM-STUDENT-ID.
           05  VALUE "NAME:"                     LINE 06 COL 05.
           05  NAME-SCR                          LINE 06 COL 15
                      PIC X(20) FROM VSAM-STUDENT-NAME.
           05  VALUE "MAJOR:"                    LINE 08 COL 05.
           05  MAJOR-SCR                         LINE 08 COL 15
                      PIC XXX   FROM VSAM-STUDENT-MAJOR.
           05  VALUE "ENTRANCE:"                 LINE 10 COL 05.
           05  VALUE "SEMESTER:"                 LINE 11 COL 10.
           05  SEM-SCR                           LINE 11 COL 20
                      PIC X     FROM VSAM-STUDENT-SEM-ENTER.
           05  VALUE "YEAR:"                     LINE 11 COL 23.
           05  YEAR-SCR                          LINE 11 COL 30
                      PIC 9999  USING VSAM-STUDENT-YR-ENTER.
           05  VALUE "P - PROCESS CHANGES"       LINE 13 COL 05.
           05  VALUE "C - CANCEL - CHANGES WILL NOT BE MADE"
                                                 LINE 14 COL 05.
           05  VALUE "RESPONSE:"                 LINE 16 COL 30.
           05  CHANGE-YEAR-SCR                   LINE 16 COL 40
                      PIC X     TO CHANGE-YEAR-ANS.
       01  ERROR-MESSAGE-SCREEN.
           05  VALUE "ERROR MESSAGE SCREEN"      BLANK SCREEN
                                                 LINE 02 COL 20.
           05  VALUE "ID #:"                     LINE 05 COL 05.
           05  ID-ERR-SCR                        LINE 05 COL 15
                      PIC XXXX  FROM ID-ANS.
           05  MSG-SCR                           LINE 07 COL 15
                      PIC X(40) FROM MSG-TO-DISPLAY.
           05  VALUE "PRESS ANY KEY TO CONTINUE" LINE 10 COL 05.
           05  ANY-KEY-ERR-SCR                   LINE 10 COL 40
                      PIC X     TO ANY-KEY-ERR-ANS.
       PROCEDURE DIVISION.
       MAINLINE.
           PERFORM A-100-INITIALIZE.
           PERFORM B-100-PROCESS.
           PERFORM C-100-TERMINATE.
           STOP RUN.
       A-100-INITIALIZE.
           OPEN I-O VSAM-FILE
                OUTPUT PRINT-FILE.
       B-100-PROCESS.
           DISPLAY MENU-SCREEN.
           ACCEPT MENU-SCREEN.
           PERFORM B-200-LOOP
               UNTIL MENU-ANS = "T".
       B-200-LOOP.
           IF VALID-MENU-ANS
               PERFORM B-300-RANDOM-ID
           ELSE
               MOVE "INVALID MENU ANSWER" TO MSG-TO-DISPLAY
               DISPLAY ERROR-MESSAGE-SCREEN
               ACCEPT ERROR-MESSAGE-SCREEN
           END-IF.
           DISPLAY MENU-SCREEN.
           ACCEPT MENU-SCREEN.
       B-300-RANDOM-ID.
           DISPLAY ENTER-ID-RANDOMLY-SCREEN.
           ACCEPT ENTER-ID-RANDOMLY-SCREEN.
           MOVE "NO " TO REC-PROCESSED.
           PERFORM B-400-RANDOM-ID-LOOP
               UNTIL RESPONSE-ID-ANS = "Q" OR REC-PROCESSED = "YES".
       B-400-RANDOM-ID-LOOP.
           IF RESPONSE-ID-ANS = "P"
               MOVE ID-ANS TO VSAM-STUDENT-ID
               READ VSAM-FILE
                   INVALID KEY
                      MOVE "RECORD NOT FOUND" TO MSG-TO-DISPLAY
                      DISPLAY ERROR-MESSAGE-SCREEN
                      ACCEPT ERROR-MESSAGE-SCREEN
                      DISPLAY ENTER-ID-RANDOMLY-SCREEN
                      ACCEPT ENTER-ID-RANDOMLY-SCREEN
                   NOT INVALID KEY
                      PERFORM B-500-PROCESS-RECORD
               END-READ
           ELSE
              IF RESPONSE-ID-ANS = "C"
                  DISPLAY ENTER-ID-RANDOMLY-SCREEN
                  ACCEPT ENTER-ID-RANDOMLY-SCREEN
              END-IF
           END-IF.
       B-500-PROCESS-RECORD.
           EVALUATE MENU-ANS
               WHEN "M"
                   PERFORM B-600-CHANGE-MAJOR
               WHEN "S"
                   PERFORM B-610-CHANGE-SEMESTER
               WHEN "Y"
                   PERFORM B-620-CHANGE-YEAR
            END-EVALUATE.
       B-600-CHANGE-MAJOR.
            DISPLAY CHANGE-MAJOR-SCREEN.
            ACCEPT CHANGE-MAJOR-SCREEN.
            IF CHANGE-MAJOR-ANS = "P"
                REWRITE VSAM-REC.
            MOVE "YES" TO REC-PROCESSED.
       B-610-CHANGE-SEMESTER.
            DISPLAY CHANGE-SEMESTER-SCREEN.
            ACCEPT CHANGE-SEMESTER-SCREEN.
            IF CHANGE-SEMESTER-ANS = "P"
                REWRITE VSAM-REC.
            MOVE "YES" TO REC-PROCESSED.
       B-620-CHANGE-YEAR.
            DISPLAY CHANGE-YEAR-SCREEN.
            ACCEPT CHANGE-YEAR-SCREEN.
            IF CHANGE-YEAR-ANS = "P"
                REWRITE VSAM-REC.
            MOVE "YES" TO REC-PROCESSED.
       C-100-TERMINATE.
           CLOSE VSAM-FILE
                 PRINT-FILE.
       U-000-DETAIL.
           MOVE SPACES TO PRINTZ.
           MOVE VSAM-STUDENT-ID TO VSAM-STUDENT-ID-PR.
           MOVE VSAM-STUDENT-NAME TO VSAM-STUDENT-NAME-PR.
           MOVE VSAM-STUDENT-MAJOR TO VSAM-STUDENT-MAJOR-PR.
           MOVE VSAM-STUDENT-SEM-ENTER TO VSAM-STUDENT-SEM-ENTER-PR.
           MOVE VSAM-STUDENT-YR-ENTER TO VSAM-STUDENT-YR-ENTER-PR.
           WRITE PRINTZ
               AFTER ADVANCING 1 LINES.