000100 Identification Division. 000200 Program-Id. FREQPGM4. 000300 Environment Division. 000400 Input-Output Section. 000500 File-Control. 000600 Select FREQFILE Assign to FREQFDD 000700 Organization is Indexed 000800 Access is Sequential 000900 Record Key is Flight-Date in File-Record 001000 File Status is Freqfile-Status 001100 . 001200 Select FREQLIST Assign to FREQLDD 001300 Organization is Sequential 001400 Access is Sequential 001500 File Status is Freqlist-Status 001600 . 001700 Data Division. 001800 File Section. 001900 FD FREQFILE. 002000 01 File-Record. 002100 88 End-Of-Freq-File Value High-Value. 002200 05 Pic X(01). 002300 05 Flight-Date Pic X(05). 002400 05 City-Pair. 002500 10 Origin Pic X(03). 002600 10 Pic X(01). 002700 10 Dest Pic X(03). 002800 05 Airline-Id Pic X(02). 002900 05 Flight-Number Pic 9(04). 003000 05 Class-Of-Travel Pic X(01). 003100 88 Tourist Value 'Y'. 003200 88 Business Value 'C'. 003300 88 Firstclass Value 'F'. 003400 05 Mileage Pic 9(05). 003500 05 Pic X(55). 003600 003700 FD FREQLIST Recording mode F. 003800 01 Listrow Pic X(120). 003900 004000*--------------------------------------- 004100 Working-Storage Section. 004200*--------------------------------------- 004300 004400 77 Mileage-Total Pic 9(08) Value 0. 004500 77 Incbonus-Value Pic 9(08) Value 0. 004600 77 Incbonus-Total Pic 9(08) Value 0. 004700 004800 01 Freqfile-Status Pic X(02). 004900 88 Freqfile-Openerror Values '01' thru '99'. 005000 01 Freqmile-Status Pic X(02). 005100 88 Freqmile-Openerror Values '01' thru '99'. 005200 01 Freqlist-Status Pic X(02). 005300 88 Freqlist-Openerror Values '01' thru '99'. 005400 005500 01 List-Blankrow. 005600 05 Pic X(120) Value Spaces. 005700 005800 01 List-Header1. 005900 05 Pic X(35) Value 'Frequent Flyer Report'. 006000 006100 01 List-Header2. 006200 05 Flight-Date Pic X(07) Value 'Date'. 006300 05 Flight-Id Pic X(05) Value 'Id'. 006400 05 Flight-Number Pic X(05) Value 'Fl#'. 006500 05 Class-Of-Travel Pic X(03) Value 'Cl'. 006600 05 City-Pair Pic X(09) Value 'C-Pair'. 006700 05 Mileage Pic X(09) Value 'Mileage'. 006800 05 Incbonus Pic X(10) Value 'Inc Bonus'. 006900 007000 01 List-Trailer. 007100 05 Pic X(25) 007200 Value 'Total Mileage '. 007300 05 Mileage Pic Z(11). 007400 05 Incbonus Pic Z(11). 007500 007600 01 List-Detail. 007700 05 Flight-Date Pic X(05). 007800 05 Pic X(02). 007900 05 Airline-Id Pic X(02). 008000 05 Pic X(02). 008100 05 Flight-Number Pic Z(04). 008200 05 Pic X(02). 008300 05 Class-Of-Travel Pic X(01). 008400 05 Pic X(02). 008500 05 City-Pair Pic X(07). 008600 05 Pic X(02). 008700 05 Mileage Pic Z(07). 008800 05 Pic X(04). 008900 05 Incbonus Pic Z(07). 009000 009100 77 MT-Freqmile Pic X(08) Value 'FREQMILE'. 009200 77 MT-Count Pic 9(03) Value 0. 009300 01 Tab-Search. 009400 05 TS-City-Pair. 009500 10 TS-Org-City Pic X(03). 009600 10 Pic X(01). 009700 10 TS-Dst-City Pic X(03). 009800 01 Mile-Table. 009900 05 City-Pair-Table Occurs 350 010000 Depending on MT-Count 010100 Ascending Key MT-City-Pair 010200 Indexed By Ndx. 010300 10 MT-City-Pair. 010400 15 MT-Org-City Pic X(03). 010500 15 Pic X(01). 010600 15 MT-Dst-Citu Pic X(03). 010700 10 Pic X(01). 010800 10 MT-Act-Miles Pic 9(05). 010900 011000*--------------------------------------- 011100 Procedure Division. 011200*--------------------------------------- 011300 Display '==> FREQREAD is starting...' 011400 Perform Open-Files 011500 Perform Write-Freq-Headers 011600 Perform Fill-Mile-Table 011700 Perform Read-Freqfile Until End-Of-Freq-File 011800 Perform Write-Freq-Trailer 011900 Perform Close-Files 012000 Display '==> FREQREAD ended normally' 012100 GoBack 012200 . 012300*------------------------------------- 012400 Read-Freqfile. 012500*------------------------------------- 012600 Read Freqfile 012700 At End 012800 Set End-Of-Freq-File to True 012900 Not At End 013000 Perform Write-Freq-Detail 013100 End-Read 013200 . 013300*------------------------------------- 013400 Calculate-Bonus. 013500*------------------------------------- 013600 Evaluate True 013700 When Mileage in File-Record Less Than 500 013800 Move 500 to Incbonus-Value 013900 Incbonus in List-Detail 014000 When Tourist 014100 Move Mileage in File-Record to 014200 Incbonus-Value 014300 Incbonus in List-Detail 014400 When Business 014500 Compute Incbonus-Value = 014600 Mileage in File-Record * 1.25 014700 Move Incbonus-Value to 014800 Incbonus in List-Detail 014900 When Firstclass 015000 Compute Incbonus-Value = 015100 Mileage in File-Record * 1.50 015200 Move Incbonus-Value to 015300 Incbonus in List-Detail 015400 End-Evaluate 015500 015600 Add Incbonus-Value to Incbonus-Total 015700 . 015800*------------------------------------- 015900 Search-City-Pair-Table. 016000*------------------------------------- 016100 Move City-Pair in File-Record 016200 to TS-City-Pair 016300 Search All City-Pair-Table 016400 At End 016500 Perform Search-Reverse-City-Pair 016600 When MT-City-Pair(Ndx) = TS-City-Pair 016700 Move MT-Act-Miles(Ndx) to 016800 Mileage in List-Detail 016900 End-Search 017000 . 017100*------------------------------------- 017200 Search-Reverse-City-Pair. 017300*------------------------------------- 017400 Move Origin in File-Record to 017500 TS-Dst-City 017600 Move Dest in File-Record to 017700 TS-Org-City 017800 Search All City-Pair-Table 017900 At End 018000 Display 'Hittar inte City-Pair: ' 018100 TS-City-Pair 018200 Move 99 to Return-Code 018300 GoBack 018400 When MT-City-Pair(Ndx) = TS-City-Pair 018500 Move MT-Act-Miles(Ndx) to 018600 Mileage in List-Detail 018700 End-Search 018800 . 018900*------------------------------------- 019000 Fill-Mile-Table. 019100*------------------------------------- 019200 Call MT-Freqmile Using Mile-Table, MT-Count 019300 . 019400*------------------------------------- 019500 Write-Freq-Headers. 019600*------------------------------------- 019700 Write Listrow from List-Header1 019800 Write Listrow from List-Blankrow 019900 Write Listrow from List-Header2 020000 Write Listrow from List-Blankrow 020100 . 020200*------------------------------------- 020300 Write-Freq-Trailer. 020400*------------------------------------- 020500 Write Listrow 020600 from List-Blankrow 020700 Move Mileage-Total to 020800 Mileage in List-Trailer 020900 Move Incbonus-Total to 021000 Incbonus in List-Trailer 021100 Write Listrow 021200 from List-Trailer 021300 . 021400*------------------------------------- 021500 Write-Freq-Detail. 021600*------------------------------------- 021700 Perform Search-City-Pair-Table 021800 Perform Calculate-Bonus 021900 Move Corr File-Record to List-Detail 022000 Add Mileage in File-Record to 022100 Mileage-Total 022200 022300 Write Listrow from List-Detail 022400 . 022500*------------------------------------- 022600 Open-Files. 022700*------------------------------------- 022800 Open Input FREQFILE 022900 If Freqfile-Openerror 023000 Display '==> Openerror: FREQFILE' 023100 Display '==> Status : ' Freqfile-Status 023200 Move 21 to Return-Code 023300 Goback 023400 End-If 023500 Display '==> FREQFILE is Open' 023600 024600 Open Output FREQLIST 024700 If Freqlist-Openerror 024800 Display '==> Openerror: FREQLIST' 024900 Display '==> Status : ' Freqlist-Status 025000 Move 23 to Return-Code 025100 Goback 025200 End-If 025300 Display '==> FREQLIST is Open' 025400 . 025500*------------------------------------- 025600 Close-Files. 025700*------------------------------------- 025800 Close FREQFILE 026000 FREQLIST 026100 . 026200 End Program FREQPGM4. 026300