Totals on the Screen Please use speaker notes for additional information!
Totals IDENTIFICATION DIVISION. PROGRAM-ID. READ1. AUTHOR. GROCER ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT PAY-FILE ASSIGN TO "A:\PAY.DAT". DATA DIVISION. FILE SECTION. FD PAY-FILE DATA RECORD IS PAY-REC. 01 PAY-REC. 05 PAY-ID PIC PAY-NAME PIC X(20). 05 PAY-TYPE PIC X. 05 PAY-RATE PIC 999V PAY-HOURS PIC 99. WORKING-STORAGE SECTION. 01 INDICATORZ. 05 EOF-IND PIC X VALUE "N". 05 CONTINUE-ANS PIC X VALUE SPACES. 01 WORK-AREAS. 05 TOT-RECORDS PIC 99 VALUE TOT-HOURS-WORKED PIC 9999 VALUE SCREEN-OUTPUT-AREAS. 05 PAY-RATE-SCR PIC ZZZ TOT-RECORDS-SCR PIC Z9. 05 TOT-HOURS-WORKED-SCR PIC Z,ZZ9. These formatted fields will display the totals on the screen. These two fields will be added to as the totals are accumulated. This has nothing to do with totals, I simply want to display the pay rate with a decimal point and suppressed leading zeros.
PROCEDURE DIVISION. MAINLINE. PERFORM A-100-STARTUP. PERFORM B-100-PROCESS. PERFORM C-100-WRAPUP. STOP RUN. A-100-STARTUP. OPEN INPUT PAY-FILE. B-100-PROCESS. READ PAY-FILE AT END MOVE "Y" TO EOF-IND. PERFORM B-200-LOOP UNTIL EOF-IND = "Y". B-200-LOOP. DISPLAY "THE ID IS " PAY-ID. DISPLAY "THE NAME IS " PAY-NAME. DISPLAY "THE PAY TYPE IS " PAY-TYPE. MOVE PAY-RATE TO PAY-RATE-SCR. DISPLAY "THE PAY RATE IS " PAY-RATE-SCR. DISPLAY "THE HOURS WORKED IS " PAY-HOURS. ADD 1 TO TOT-RECORDS. ADD PAY-HOURS TO TOT-HOURS-WORKED. DISPLAY " ". DISPLAY "PRESS ENTER TO CONTINUE". ACCEPT CONTINUE-ANS. READ PAY-FILE AT END MOVE "Y" TO EOF-IND. Totals As the records are processed, I accumulate the totals. I want to count the total number of records so I add 1 to TOT-RECORDS. I want to accumulate the total of what is in all of the PAY- HOURS fields, so I add PAY- HOURS to TOT-HOURS- WORKED. This has nothing to do with the totals, but I want to display PAY-RATE with a decimal point, so I move it to the edited field shown on the previous slide.
C-100-WRAPUP. MOVE TOT-RECORDS TO TOT-RECORDS-SCR. DISPLAY "THE TOTAL NUMBER OF RECORDS IS: " TOT-RECORDS-SCR. MOVE TOT-HOURS-WORKED TO TOT-HOURS-WORKED-SCR. DISPLAY "THE TOTAL HOURS WORKED IS: " TOT-HOURS-WORKED-SCR. CLOSE PAY-FILE. Totals At end of file, processing terminates and control passes to C-100-WRAPUP. In that paragraph I move the totals that I have been accumulating to an edited area to suppress leading zeros and I display the totals with a literal identifying the total.
1111John Doe F Linda Harris P Susan Ash F David Costa F Ann French F Richard Morse P Totals
1111John Doe F WORK-AREAS. 05 TOT-RECORDS PIC 99 VALUE TOT-HOURS-WORKED PIC 9999 VALUE 0. TOT-RECORDS TOT-HOURS-WORKED Linda Harris P TOT-RECORDS TOT-HOURS-WORKED Susan Ash F TOT-RECORDS TOT-HOURS-WORKED 3100
5555Ann French F TOT-RECORDS TOT-HOURS-WORKED 3100 Totals 4444David Costa F TOT-RECORDS TOT-HOURS-WORKED 4140 After processing three records on previous slide. 6666Richard Morse P TOT-RECORDS TOT-HOURS-WORKED 5175 TOT-RECORDS TOT-HOURS-WORKED 6190