home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / cobol / nrcobol1a / cobfiles / flights.cob < prev    next >
Text File  |  1997-06-25  |  22KB  |  540 lines

  1.        IDENTIFICATION DIVISION.
  2.        PROGRAM-ID.   FLIGHTS.
  3.       *PROGRAM DISCRIPTION.
  4.       *  A program to update and print data from an indexed file called
  5.       * 'FLIGHT. FILE'.Used to translate value codes from the input file
  6.       * to a more readable form are two lookup tables called 'AIRPLANES'
  7.       * and 'AIRPORTS'.
  8.       *  AIRPLANE, contains the airplanes' code and their corresponding
  9.       * discription. AIRPORTS ,contains the airports' code and their
  10.       * corresponding airport names.  PRT: version.
  11.       *
  12.       *AUTHOR.        cHArRiOTt.
  13.       *INSTALLATION.
  14.       *DATE-WRITTEN.  SEP 28th 89.
  15.       *DATE-COMPILLED.
  16.       *SECURITY.
  17.        ENVIRONMENT DIVISION.
  18.  
  19.        CONFIGURATION SECTION.
  20.        SOURCE-COMPUTER.   AMSTRAD 1512.
  21.        OBJECT-COMPUTER.
  22.        INPUT-OUTPUT SECTION. 
  23.        FILE-CONTROL.
  24.             SELECT           AIRPORT
  25.             ASSIGN TO        DISK
  26.             ORGANIZATION IS  INDEXED
  27.             ACCESS MODE  IS  DYNAMIC
  28.             RECORD KEY   IS  ER-AIRPORT-CODE
  29.             FILE STATUS  IS  WS-AIRPORT-STATUS. 
  30.  
  31.             SELECT           AIRPLANE
  32.             ASSIGN TO        DISK
  33.             ORGANIZATION IS  LINE SEQUENTIAL
  34.             ACCESS MODE  IS  SEQUENTIAL
  35.             FILE STATUS  IS  WS-AIRPLANE-STATUS.
  36.  
  37.             SELECT           FLIGHT
  38.             ASSIGN TO        DISK 
  39.             ORGANIZATION IS  INDEXED
  40.             ACCESS MODE  IS  DYNAMIC
  41.             RECORD KEY   IS  ER-FLIGHT-NUMBER
  42.             FILE STATUS  IS  WS-FLIGHT-STATUS.
  43.  
  44.             SELECT           AIR-PRINT
  45.             ASSIGN TO        PRINTER
  46.             ORGANIZATION IS  LINE SEQUENTIAL
  47.             ACCESS MODE  IS  SEQUENTIAL
  48.             FILE STATUS  IS  WS-PRINTER-STATUS.
  49.       *
  50.        DATA DIVISION.
  51.        FILE SECTION.
  52.        FD AIRPORT
  53.             LABEL RECORD IS  STANDARD
  54.             VALUE OF FILE-ID IS "AIRPORTS.OUT".
  55.        01 ER-AIRPORT-REC.
  56.            03 ER-AIRPORT-CODE      PIC 99.
  57.            03 ER-AIRPORT-NAME      PIC X(15).
  58.  
  59.        FD AIRPLANE
  60.             LABEL RECORD IS STANDARD
  61.             VALUE OF FILE-ID IS "AIRPLANE".
  62.        01 ER-AIRPLANE-REC.
  63.            03 ER-AIRPLANE-CODE     PIC X(4).
  64.            03 ER-MAKE-MODEL        PIC X(16).
  65.  
  66.        FD FLIGHT
  67.            LABEL RECORD IS STANDARD
  68.            VALUE OF FILE-ID IS "FLIGHTOUT.FIL".
  69.        01 ER-FLIGHT-REC.
  70.            03 ER-FLIGHT-NUMBER     PIC 9(5).
  71.            03 ER-AIRPLANE-ID       PIC 9(5).
  72.            03 ER-AIRPLANE-MK-CODE  PIC X(4).
  73.            03 ER-FLIGHT-ORG-CODE   PIC 99.
  74.            03 ER-FLIGHT-DES-CODE   PIC 99.
  75.            03 ER-SEATS-FILLED      PIC 999.
  76.            03 ER-SEATS-TABLE.                                 
  77.               05 ER-SEAT-TABLE     OCCURS 10 TIMES.
  78.                  08 ER-SEAT-LETTER OCCURS  6 TIMES.
  79.                     10 ER-SEAT     PIC 9(4).
  80.  
  81.        FD AIR-PRINT
  82.             LABEL RECORD IS OMITTED
  83.             VALUE OF FILE-ID IS "PRT:".
  84.        01 OUT-PRINT-REC.
  85.            03 FILLER               PIC X(80).
  86.       *
  87.        WORKING-STORAGE SECTION.
  88.        01 WS-AIRPORT-REC.
  89.            03 WS-AIRPORT-CODE      PIC 99       VALUE 99.
  90.            03 WS-AIRPORT-NAME      PIC X(15).
  91.       *
  92.        01 WS-AIRPLANE-REC.
  93.            03 WS-AIRPLANE-ARRAY    OCCURS 10 TIMES.
  94.              05 WS-AIRPLANE-CODE   PIC X(4)     VALUE "0000".
  95.              05 WS-MAKE-MODEL      PIC X(16).
  96.       *
  97.        01 WS-FLIGHT-REC.
  98.            03 WS-FLIGHT-NUMBER     PIC 9(5)     VALUE 99.
  99.            03 WS-AIRPLANE-ID       PIC 9(5).
  100.            03 WS-AIRPLANE-MK-CODE  PIC X(4).
  101.            03 WS-FLIGHT-ORG-CODE   PIC 99.
  102.            03 WS-FLIGHT-DES-CODE   PIC 99.
  103.            03 WS-SEATS-FILLED      PIC 999.
  104.            03 WS-SEATS-TABLE.
  105.               05 WS-SEAT-TABLE     OCCURS 10 TIMES.
  106.                  08 WS-SEAT-LETTER OCCURS  6 TIMES.
  107.                     10 WS-SEAT     PIC 9(4).
  108.       *
  109.       *
  110.        01 WS-AIRPLANE-END-FLAG      PIC X       VALUE " ".
  111.            88 WS-AIRPLANE-END                    VALUE "S".
  112.        01 WS-AIRPORT-END-FLAG      PIC X        VALUE " ".
  113.            88 WS-AIRPORT-END                     VALUE "S".
  114.        01 WS-FLIGHT-END-FLAG       PIC X        VALUE " ".
  115.            88 WS-FLIGHT-END                      VALUE "S".
  116.        01 WS-STOP-RUN-FLAG         PIC X        VALUE " ".
  117.        01 WS-ABORT-FLAG            PIC X        VALUE " ".
  118.  
  119.        01 WS-FLIGHT-STATUS         PIC XX       VALUE "00".
  120.        01 WS-AIRPLANE-STATUS       PIC XX       VALUE "00".
  121.        01 WS-AIRPORT-STATUS        PIC XX       VALUE "00".
  122.        01 WS-PRINTER-STATUS        PIC XX       VALUE "00".
  123.  
  124.        01 WS-RECORD-COUNTER        PIC 99       VALUE 00.
  125.        01 WS-PAGE-COUNTER          PIC 99       VALUE 00.
  126.        01 WS-LINE-COUNTER          PIC 99       VALUE 00.
  127.        01 WS-SEAT-ROW              PIC 99       VALUE 00.
  128.        01 WS-SEAT-COLUMN           PIC 99       VALUE 00.
  129.        01 WS-SEAT-NUMBER           PIC 9999     VALUE 0000.
  130.        01 WS-FLIGHT-DEPARTURES     PIC X(15)    VALUE SPACES.
  131.        01 WS-FLIGHT-ARRIVALS       PIC X(15)    VALUE SPACES.
  132.        01 WS-AIRPLANE-NAME         PIC X(16)    VALUE SPACES.
  133.        01 WS-NUMBER-OF-FLIGHTS     PIC 999      VALUE 000.
  134.        01 WS-TOTAL-SEATS-USED      PIC 9(5)     VALUE 000.
  135.        01 WS-TOTAL-SEATS           PIC 9(5)     VALUE 000.
  136.        01 WS-PERCENT-SEATS-FILLED  PIC 9(5)     VALUE 000.
  137.        01 WS-AVERAGE-SEATS-USED    PIC 9(5)     VALUE 000.
  138.        01 WS-AVG-PERCENT-SEATS-FILLED PIC 9(5)   VALUE 000.
  139.        01 WS-REAL-DATE.
  140.            03 WS-REAL-YEAR         PIC XX.
  141.            03 WS-REAL-MONTH        PIC XX.
  142.            03 WS-REAL-DAY          PIC XX.
  143.        01 WS-TEMP-DATE.
  144.            03 WS-TEMP-DAY          PIC XX.
  145.            03 FILLER               PIC X        VALUE "/".
  146.            03 WS-TEMP-MONTH        PIC XX.
  147.            03 FILLER               PIC X        VALUE "/".
  148.            03 WS-TEMP-YEAR         PIC XX.
  149.        01 WS-RESPONCE              PIC X        VALUE " ".
  150.            88 WS-RESPONCE-C        VALUE "C" "c".
  151.            88 WS-RESPONCE-R        VALUE "R" "r".
  152.            88 WS-RESPONCE-Q        VALUE "Q" "q".
  153.            88 WS-RESPONCE-Y        VALUE "Y" "y".
  154.            88 WS-RESPONCE-N        VALUE "N" "n".
  155.            88 WS-RESPONCE-YN       VALUE "Y" "y"
  156.                                          "N" "n".
  157.        01 PRINT-PROG-TITLE.
  158.            03 FILLER               PIC X(5)  VALUE "PAGE ".
  159.            03 WS-PRT-PAGE-COUNTER  PIC 99.
  160.            03 FILLER               PIC X(20) VALUE SPACES.
  161.            03 FILLER               PIC X(25) VALUE
  162.               "AIRLINE SEAT USAGE REPORT".
  163.            03 FILLER               PIC X(20) VALUE SPACES.
  164.            03 WS-PRT-TEMP-DATE     PIC X(8).
  165.        01 PRINT-RECORD.
  166.            03 PRT-AIRPLANE-ID.
  167.               05 FILLER               PIC X(33) VALUE
  168.                "     AIRPLANE-ID               : ".
  169.               05 WS-PRT-AIRPLANE-ID   PIC 9(5).
  170.            03 PRT-AIRPLANE-NAME.
  171.               05 FILLER               PIC X(33) VALUE 
  172.                "     AIRPLANE NAME             : ".
  173.               05 WS-PRT-AIRPLANE-NAME PIC X(16).
  174.            03 PRT-AIRPORT-ORG.
  175.               05 FILLER               PIC X(33) VALUE
  176.                "     AIRPORT - ORIGINATION     : ".
  177.               05 WS-PRT-AIRPORT-ORG   PIC X(15).
  178.            03 PRT-AIRPORT-DES.
  179.               05 FILLER               PIC X(33) VALUE
  180.                "     AIRPORT - DESTINATION     : ".
  181.               05 WS-PRT-AIRPORT-DES   PIC X(15).
  182.            03 PRT-SEATS-FILLED.
  183.               05 FILLER               PIC X(33) VALUE
  184.                "     SEATS FILLED              : ".
  185.               05 WS-PRT-SEATS-FILLED  PIC ZZ9.
  186.            03 PRT-PERCENT-SEATS-FILLED.
  187.               05 FILLER               PIC X(34) VALUE
  188.                "     PERCENTAGE OF SEATS FILLED: %".
  189.               05 WS-PRT-PERCENT-SEATS-FILLED    PIC ZZ9.
  190.        01 PRINT-TOTALS.
  191.            03 PRT-NUMBER-OF-FLIGHTS.
  192.               05 FILLER               PIC X(33) VALUE
  193.                "     NUMBER OF FLIGHTS         : ".
  194.               05 WS-PRT-NUMBER-OF-FLIGHTS       PIC ZZ9.
  195.            03 PRT-TOTAL-SEATS-USAGE.
  196.               05 FILLER               PIC X(33) VALUE
  197.                "     TOTAL SEATS USAGE         : ".
  198.               05 WS-PRT-TOTAL-SEATS-USAGE       PIC ZZ9.
  199.            03 PRT-AVG-PERCENT-SEATS-FILLED.
  200.               05 FILLER               PIC X(34) VALUE
  201.                "     AVERAGE % OF TOTAL SEATS  : %".
  202.               05 WS-PRT-AVG-PERC-SEATS-FILLED   PIC ZZ9.
  203.       *
  204.        SCREEN SECTION.
  205.        01 MENU.
  206.            03 LINE 10 COLUMN 30    HIGHLIGHT VALUE "MENU".
  207.            03 LINE 13 COLUMN 30    VALUE "C)hange flight data".
  208.            03 LINE 14 COLUMN 30    VALUE "R)eport listing".
  209.            03 LINE 15 COLUMN 30    VALUE "Q)uit program".
  210.        01 MENU-RESPONCE.
  211.            03 LINE 17 COLUMN 28    VALUE ">> <<".
  212.            03 LINE 17 COLUMN 30    PIC X USING WS-RESPONCE AUTO.
  213.        01 SC-FLIGHT-NUMBER.
  214.            03 LINE 6 COLUMN 5  VALUE "FLIGHT NUMBER          : ".
  215.            03 LINE 6 COLUMN 30 PIC 9(5) USING WS-FLIGHT-NUMBER.
  216.        01 SC-FLIGHT-REC.
  217.            03 LINE 7 COLUMN 5   VALUE "AIRPLANE ID           : ".
  218.            03 LINE 7 COLUMN 30  PIC 9(5) USING WS-AIRPLANE-ID.
  219.            03 LINE 8 COLUMN 5   VALUE "AIRPLANE MAKE CODE    : ".
  220.            03 LINE 8 COLUMN 30  PIC X(4) USING  WS-AIRPLANE-MK-CODE.
  221.        01 SC-FLIGHT-PLAN.
  222.            03 LINE 10 COLUMN 5   VALUE "FLIGHT ORIGIN CODE    : ".
  223.            03 LINE 10 COLUMN 30  PIC 99 USING  WS-FLIGHT-ORG-CODE.
  224.            03 LINE 11 COLUMN 5   VALUE "FLIGHT DESTIN CODE    : ".
  225.            03 LINE 11 COLUMN 30  PIC 99 USING  WS-FLIGHT-DES-CODE.
  226.        01 SC-SEATS-FILLED.
  227.            03 LINE 14 COLUMN 5  VALUE "SEATS FILLED          : ".
  228.            03 LINE 14 COLUMN 30 PIC 999 USING  WS-SEATS-FILLED.
  229.        01 SC-SEAT-TABLE.
  230.            03 LINE 16 COLUMN 5  VALUE "SEAT ROW              : ".
  231.            03 LINE 16 COLUMN 30 PIC 99 USING WS-SEAT-ROW.
  232.            03 LINE 17 COLUMN 5  VALUE "SEAT COLUMN           : ".
  233.            03 LINE 17 COLUMN 30 PIC 9  USING WS-SEAT-COLUMN.
  234.        01 SC-SEAT-ENTRY.
  235.            03 LINE 18 COLUMN 5  VALUE "SEAT NUMBER           : ".
  236.            03 LINE 18 COLUMN 30 PIC 9999 USING WS-SEAT-NUMBER.
  237.       *
  238.        01 RECORD-AMOUNT.
  239.            03 LINE 20 COLUMN 5   VALUE "RECORD NUMBER         : ".
  240.            03 LINE 20 COLUMN 30  PIC 99 USING WS-RECORD-COUNTER.
  241.        01 SC-INVALID-KEY.
  242.            03 LINE 21 COLUMN 5   
  243.                VALUE "INVALID KEY  FLIGHT NUMBER  'ALREADY EXITS'".
  244.        01 RESPONCE.
  245.            03 LINE 23 COLUMN 5   
  246.                VALUE "IS IT O.K TO WRITE RECORD TO FILE  >".
  247.        01 RESPONCE-LINE.
  248.            03 LINE 23 COLUMN 41  PIC X USING WS-RESPONCE AUTO.
  249.        01 RESPONCE-BLANK.
  250.            03 LINE 23 COLUMN 5   BLANK LINE.
  251.            03 LINE 21 COLUMN 5   BLANK LINE.
  252.       *
  253.        01 BLANK-SCREEN.
  254.            03 BLANK SCREEN.
  255.        01 PROG-DISCRIPTION.
  256.            03 LINE 1 COLUMN 5  VALUE 
  257.                 "THIS PROGRAM PRINTS AND/OR UPDATES THE CONTENTS 'FLIGHT
  258.       -       " FILE' AS DIRECTED".
  259.        01 INPUT-DISCRIPTION.
  260.            03 LINE 3 COLUMN 5  HIGHLIGHT VALUE 
  261.               "THIS SCREEN ALLOWS ENTRY OF 'FLIGHT' FILE DETAILS".
  262.        01 PROG-FINISH.
  263.            03 LINE 24  COLUMN 5 VALUE "TASK COMPLETE".
  264.        01 ERROR-MESSG.
  265.            03 LINE 20  COLUMN 5 VALUE 
  266.               "FILE WOULD NOT OPEN  :FLIGHT :PLANE :PORT :PRINT:".
  267.            03 LINE 21  COLUMN 5 VALUE
  268.               "STATUS ERROR CODES   :       :      :     :     :".
  269.            03 LINE 21  COLUMN 29  HIGHLIGHT PIC XX
  270.               FROM WS-FLIGHT-STATUS.
  271.            03 LINE 21  COLUMN 37  HIGHLIGHT PIC XX
  272.               FROM WS-AIRPLANE-STATUS.
  273.            03 LINE 21  COLUMN 43  HIGHLIGHT PIC XX
  274.               FROM WS-AIRPORT-STATUS.
  275.            03 LINE 21  COLUMN 50  HIGHLIGHT PIC XX
  276.               FROM WS-PRINTER-STATUS.
  277.       *******************************************
  278.       *
  279.        PROCEDURE DIVISION.
  280.        0000-MAIN.
  281.            DISPLAY BLANK-SCREEN.
  282.            DISPLAY PROG-DISCRIPTION.
  283.            OPEN OUTPUT  AIR-PRINT
  284.                 INPUT   AIRPORT
  285.                 INPUT   AIRPLANE
  286.                 I-O     FLIGHT.
  287.                 IF WS-FLIGHT-STATUS    = "00" AND
  288.                    WS-AIRPLANE-STATUS  = "00" AND
  289.                    WS-AIRPORT-STATUS   = "00" AND
  290.                    WS-PRINTER-STATUS   = "00" 
  291.                        PERFORM 1000-MENU UNTIL WS-STOP-RUN-FLAG = "S"
  292.                    ELSE
  293.                        DISPLAY ERROR-MESSG.
  294.            DISPLAY PROG-FINISH.
  295.            CLOSE       FLIGHT
  296.                        AIRPLANE
  297.                        AIRPORT
  298.                        AIR-PRINT.
  299.            STOP RUN.
  300.       *
  301.       *******************************************
  302.       *
  303.        1000-MENU.
  304.            ACCEPT WS-REAL-DATE FROM DATE.
  305.            MOVE WS-REAL-DAY   TO WS-TEMP-DAY.
  306.            MOVE WS-REAL-MONTH TO WS-TEMP-MONTH.
  307.            MOVE WS-REAL-YEAR  TO WS-TEMP-YEAR.
  308.  
  309.            MOVE " " TO WS-RESPONCE.
  310.            DISPLAY BLANK-SCREEN.
  311.            DISPLAY PROG-DISCRIPTION.
  312.            DISPLAY MENU.
  313.            ACCEPT  MENU-RESPONCE.
  314.            IF WS-RESPONCE-C 
  315.                   PERFORM 2000-CHANGE-FLIGHT
  316.              ELSE 
  317.              IF WS-RESPONCE-R
  318.                     PERFORM 3000-REPORT-FLIGHT
  319.                ELSE
  320.                IF WS-RESPONCE-Q
  321.                       MOVE "S" TO WS-STOP-RUN-FLAG.
  322.       *
  323.       *************************************************
  324.       *
  325.        2000-CHANGE-FLIGHT.
  326.            DISPLAY BLANK-SCREEN.
  327.            DISPLAY PROG-DISCRIPTION.
  328.            DISPLAY INPUT-DISCRIPTION.
  329.            MOVE ZERO TO WS-FLIGHT-NUMBER.
  330.            DISPLAY SC-FLIGHT-NUMBER.
  331.            ACCEPT  SC-FLIGHT-NUMBER.
  332.            MOVE WS-FLIGHT-NUMBER TO ER-FLIGHT-NUMBER.
  333.            READ FLIGHT INTO WS-FLIGHT-REC
  334.                  INVALID KEY MOVE "F" TO WS-ABORT-FLAG.
  335.  
  336.            MOVE 1 TO WS-SEAT-ROW.
  337.            MOVE 1 TO WS-SEAT-COLUMN.
  338.  
  339.            DISPLAY SC-FLIGHT-REC.
  340.            DISPLAY SC-FLIGHT-PLAN.
  341.            DISPLAY SC-SEATS-FILLED.
  342.            DISPLAY SC-SEAT-TABLE.
  343.            DISPLAY SC-SEAT-ENTRY.
  344.  
  345.            ACCEPT  SC-FLIGHT-REC.
  346.            PERFORM 2100-FLIGHT-PLAN
  347.                    UNTIL WS-FLIGHT-ORG-CODE NOT EQUAL WS-FLIGHT-DES-CODE.
  348.            PERFORM 2200-SEATS-TABLE
  349.                    UNTIL WS-SEAT-ROW IS GREATER THAN 10.
  350.            MOVE " " TO WS-RESPONCE.
  351.            PERFORM 2300-RESPONCE UNTIL WS-RESPONCE-YN.
  352.            IF WS-RESPONCE-Y
  353.                  MOVE WS-FLIGHT-REC TO ER-FLIGHT-REC
  354.                  WRITE ER-FLIGHT-REC INVALID KEY
  355.                     DISPLAY SC-INVALID-KEY.
  356.       *
  357.       ********************************************
  358.       *
  359.        2100-FLIGHT-PLAN.
  360.            ACCEPT SC-FLIGHT-PLAN.
  361.       *
  362.        2200-SEATS-TABLE.
  363.            MOVE 1 TO WS-SEAT-COLUMN.
  364.            PERFORM 2210-SEATS-ENTRY 
  365.                         UNTIL WS-SEAT-COLUMN IS GREATER THAN 6.
  366.            ADD 1 TO WS-SEAT-ROW.
  367.       *
  368.        2210-SEATS-ENTRY.
  369.            MOVE WS-SEAT (WS-SEAT-ROW WS-SEAT-COLUMN) TO WS-SEAT-NUMBER.
  370.            DISPLAY SC-SEAT-TABLE.
  371.            DISPLAY SC-SEAT-ENTRY.
  372.            ACCEPT  SC-SEAT-ENTRY.
  373.            IF WS-SEAT (WS-SEAT-ROW WS-SEAT-NUMBER)  EQUAL ZERO AND
  374.                             WS-SEAT-NUMBER NOT      EQUAL ZERO
  375.                             ADD 1 TO WS-SEATS-FILLED
  376.                             DISPLAY  SC-SEATS-FILLED
  377.              ELSE
  378.              IF WS-SEAT (WS-SEAT-ROW WS-SEAT-NUMBER) NOT EQUAL ZERO AND
  379.                                WS-SEAT-NUMBER            EQUAL ZERO
  380.                                SUBTRACT 1 FROM WS-SEATS-FILLED
  381.                                DISPLAY    SC-SEATS-FILLED.
  382.            MOVE WS-SEAT-NUMBER TO WS-SEAT (WS-SEAT-ROW WS-SEAT-COLUMN).
  383.            ADD 1 TO WS-SEAT-COLUMN.
  384.       *
  385.       ******************************************
  386.       *
  387.        2300-RESPONCE.
  388.            DISPLAY RESPONCE.
  389.            ACCEPT  RESPONCE-LINE.
  390.       *
  391.       *************************************************
  392.       *
  393.        3000-REPORT-FLIGHT.
  394.            DISPLAY BLANK-SCREEN.
  395.            DISPLAY PROG-DISCRIPTION.
  396.  
  397.            MOVE ZERO TO WS-RECORD-COUNTER.
  398.            PERFORM 3100-READ-AIRPLANE UNTIL WS-AIRPLANE-END.
  399.            MOVE ZERO TO WS-FLIGHT-NUMBER.
  400.            START FLIGHT KEY IS GREATER THAN WS-FLIGHT-NUMBER 
  401.                  INVALID KEY DISPLAY SC-INVALID-KEY.
  402.  
  403.            MOVE ZERO TO WS-PAGE-COUNTER.
  404.            MOVE 56   TO WS-LINE-COUNTER.
  405.            PERFORM 3200-READ-FLIGHT UNTIL WS-FLIGHT-END.
  406.  
  407.            MULTIPLY WS-NUMBER-OF-FLIGHTS BY 60
  408.                                   GIVING WS-TOTAL-SEATS.
  409.            MULTIPLY WS-TOTAL-SEATS-USED  BY 100
  410.                                   GIVING WS-AVG-PERCENT-SEATS-FILLED.
  411.            DIVIDE WS-AVG-PERCENT-SEATS-FILLED BY WS-TOTAL-SEATS
  412.                                   GIVING WS-AVG-PERCENT-SEATS-FILLED.
  413.  
  414.            PERFORM 3300-FLIGHT-TOTALS.
  415.       *
  416.       ******************************************************
  417.       *
  418.        3100-READ-AIRPLANE.
  419.            ADD 1 TO WS-RECORD-COUNTER.
  420.            READ AIRPLANE AT END
  421.               MOVE "S" TO WS-AIRPLANE-END-FLAG.
  422.            IF NOT WS-AIRPLANE-END
  423.               MOVE ER-AIRPLANE-REC TO 
  424.                    WS-AIRPLANE-ARRAY (WS-RECORD-COUNTER).
  425.       *
  426.       ******************************************************
  427.       *
  428.        3200-READ-FLIGHT.
  429.            MOVE SPACE TO WS-ABORT-FLAG.
  430.            READ FLIGHT NEXT RECORD
  431.                 INTO WS-FLIGHT-REC
  432.                 AT END MOVE "S" TO WS-FLIGHT-END-FLAG.
  433.            IF NOT WS-FLIGHT-END
  434.                 MOVE WS-FLIGHT-ORG-CODE TO ER-AIRPORT-CODE
  435.                 READ AIRPORT 
  436.                      INVALID KEY MOVE "A" TO WS-ABORT-FLAG
  437.                 END-READ
  438.                 MOVE ER-AIRPORT-NAME TO WS-FLIGHT-DEPARTURES
  439.  
  440.                 MOVE WS-FLIGHT-DES-CODE TO ER-AIRPORT-CODE
  441.                 READ AIRPORT
  442.                      INVALID KEY MOVE "B" TO WS-ABORT-FLAG
  443.                 END-READ
  444.                 MOVE ER-AIRPORT-NAME TO WS-FLIGHT-ARRIVALS
  445.  
  446.                 SET WS-RECORD-COUNTER TO 1
  447.                 SEARCH WS-AIRPLANE-ARRAY
  448.                     WHEN WS-AIRPLANE-CODE (WS-RECORD-COUNTER) EQUAL
  449.                     WS-AIRPLANE-MK-CODE
  450.                     MOVE WS-MAKE-MODEL TO WS-AIRPLANE-NAME
  451.                 END-SEARCH
  452.                 ADD 1 TO WS-NUMBER-OF-FLIGHTS
  453.                 ADD WS-SEATS-FILLED TO WS-TOTAL-SEATS-USED
  454.                 MULTIPLY WS-SEATS-FILLED BY 10
  455.                             GIVING WS-PERCENT-SEATS-FILLED
  456.                 DIVIDE WS-PERCENT-SEATS-FILLED BY 6
  457.                             GIVING WS-PERCENT-SEATS-FILLED
  458.  
  459.                 IF WS-LINE-COUNTER GREATER THAN 55
  460.                         PERFORM 3210-PRINT-FLIGHT-TITLE
  461.                         PERFORM 3220-PRINT-FLIGHT-REC
  462.                   ELSE
  463.                         PERFORM 3220-PRINT-FLIGHT-REC
  464.  
  465.            END-IF.
  466.       *
  467.       *************************************************************
  468.       *
  469.        3210-PRINT-FLIGHT-TITLE.
  470.            ADD 1 TO WS-PAGE-COUNTER.
  471.            MOVE 2 TO WS-LINE-COUNTER.
  472.  
  473.            MOVE SPACES TO OUT-PRINT-REC.
  474.            MOVE WS-PAGE-COUNTER TO WS-PRT-PAGE-COUNTER.
  475.            MOVE WS-TEMP-DATE TO WS-PRT-TEMP-DATE.
  476.            MOVE PRINT-PROG-TITLE TO OUT-PRINT-REC.
  477.            WRITE OUT-PRINT-REC AFTER PAGE.
  478.  
  479.            MOVE SPACES TO OUT-PRINT-REC.
  480.            WRITE OUT-PRINT-REC AFTER 1.
  481.       *
  482.       **************************************************************
  483.       *
  484.        3220-PRINT-FLIGHT-REC.
  485.            MOVE WS-FLIGHT-NUMBER TO WS-PRT-AIRPLANE-ID.
  486.            MOVE SPACES TO OUT-PRINT-REC.
  487.            MOVE PRT-AIRPLANE-ID TO OUT-PRINT-REC.
  488.            WRITE OUT-PRINT-REC AFTER 1.
  489.  
  490.            MOVE WS-AIRPLANE-NAME TO WS-PRT-AIRPLANE-NAME.
  491.            MOVE SPACES TO OUT-PRINT-REC.
  492.            MOVE PRT-AIRPLANE-NAME TO OUT-PRINT-REC.
  493.            WRITE OUT-PRINT-REC AFTER 1.
  494.  
  495.            MOVE WS-FLIGHT-DEPARTURES TO WS-PRT-AIRPORT-ORG.
  496.            MOVE SPACES TO OUT-PRINT-REC.
  497.            MOVE PRT-AIRPORT-ORG TO OUT-PRINT-REC.
  498.            WRITE OUT-PRINT-REC AFTER 1.
  499.  
  500.            MOVE WS-FLIGHT-ARRIVALS TO WS-PRT-AIRPORT-DES.
  501.            MOVE SPACES TO OUT-PRINT-REC.
  502.            MOVE PRT-AIRPORT-DES TO OUT-PRINT-REC.
  503.            WRITE OUT-PRINT-REC AFTER 1.
  504.  
  505.            MOVE WS-SEATS-FILLED TO WS-PRT-SEATS-FILLED.
  506.            MOVE SPACES TO OUT-PRINT-REC.
  507.            MOVE PRT-SEATS-FILLED TO OUT-PRINT-REC.
  508.            WRITE OUT-PRINT-REC AFTER 1.
  509.  
  510.            MOVE WS-PERCENT-SEATS-FILLED TO WS-PRT-PERCENT-SEATS-FILLED.
  511.            MOVE SPACES TO OUT-PRINT-REC.
  512.            MOVE PRT-PERCENT-SEATS-FILLED TO OUT-PRINT-REC.
  513.            WRITE OUT-PRINT-REC AFTER 2.
  514.  
  515.            ADD 7 TO WS-LINE-COUNTER.
  516.       *
  517.       **************************************************************
  518.       *
  519.        3300-FLIGHT-TOTALS.
  520.            MOVE SPACES TO OUT-PRINT-REC.
  521.            MOVE WS-NUMBER-OF-FLIGHTS TO WS-PRT-NUMBER-OF-FLIGHTS.
  522.            MOVE PRT-NUMBER-OF-FLIGHTS TO OUT-PRINT-REC.
  523.            WRITE OUT-PRINT-REC AFTER 1.
  524.  
  525.            MOVE SPACES TO OUT-PRINT-REC.
  526.            MOVE WS-TOTAL-SEATS-USED TO WS-PRT-TOTAL-SEATS-USAGE.
  527.            MOVE PRT-TOTAL-SEATS-USAGE TO OUT-PRINT-REC.
  528.            WRITE OUT-PRINT-REC AFTER 1.
  529.  
  530.            MOVE SPACES TO OUT-PRINT-REC.
  531.            MOVE WS-AVG-PERCENT-SEATS-FILLED TO 
  532.                 WS-PRT-AVG-PERC-SEATS-FILLED.
  533.            MOVE PRT-AVG-PERCENT-SEATS-FILLED TO OUT-PRINT-REC.
  534.            WRITE OUT-PRINT-REC AFTER 1.
  535.  
  536.            MOVE SPACES TO OUT-PRINT-REC.
  537.            WRITE OUT-PRINT-REC AFTER 1.
  538.       *
  539.       **************************************************************
  540.