Presentation is loading. Please wait.

Presentation is loading. Please wait.

Totals on the Screen Please use speaker notes for additional information!

Similar presentations


Presentation on theme: "Totals on the Screen Please use speaker notes for additional information!"— Presentation transcript:

1 Totals on the Screen Please use speaker notes for additional information!

2 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 9999. 05 PAY-NAME PIC X(20). 05 PAY-TYPE PIC X. 05 PAY-RATE PIC 999V99. 05 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 0. 05 TOT-HOURS-WORKED PIC 9999 VALUE 0. 01 SCREEN-OUTPUT-AREAS. 05 PAY-RATE-SCR PIC ZZZ.99. 05 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.

3 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.

4 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.

5 1111John Doe F0450040 2222Linda Harris P0250020 3333Susan Ash F0500040 4444David Costa F0500040 5555Ann French F0340035 6666Richard Morse P0200015 Totals

6 1111John Doe F0450040 01 WORK-AREAS. 05 TOT-RECORDS PIC 99 VALUE 0. 05 TOT-HOURS-WORKED PIC 9999 VALUE 0. TOT-RECORDS TOT-HOURS-WORKED 1 40 2222Linda Harris P0250020 TOT-RECORDS TOT-HOURS-WORKED 260 3333Susan Ash F0500040 TOT-RECORDS TOT-HOURS-WORKED 3100

7 5555Ann French F0340035 TOT-RECORDS TOT-HOURS-WORKED 3100 Totals 4444David Costa F0500040 TOT-RECORDS TOT-HOURS-WORKED 4140 After processing three records on previous slide. 6666Richard Morse P0200015 TOT-RECORDS TOT-HOURS-WORKED 5175 TOT-RECORDS TOT-HOURS-WORKED 6190


Download ppt "Totals on the Screen Please use speaker notes for additional information!"

Similar presentations


Ads by Google