000100 Identification Division. 000200 Program-Id. FREQPGM5. 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 Date-Row1. 005600 05 Pic X(20) Value 'Printed :'. 005700 05 Date-Pgm-Date-Row1 Pic X(50) Value Space. 005800 005900 01 Date-Row2. 006000 05 Pic X(20) Value 'Valid Until :'. 006100 05 Date-Pgm-Date-Row2 Pic X(50) Value Space. 006200 006300 77 Date-Pgm Pic X(08) Value 'FREQDATE'. 006400 77 Date-Pgm-Parm-Status Pic 9. 006500 88 Parm-Error Value 0. 006600 88 Parm-OK Value 1. 006700 006800 01 List-Blankrow. 006900 05 Pic X(120) Value Spaces. 007000 007100 01 List-Header1. 007200 05 Pic X(35) Value 'Frequent Flyer Report'. 007300 007400 01 List-Header2. 007500 05 Flight-Date Pic X(07) Value 'Date'. 007600 05 Flight-Id Pic X(05) Value 'Id'. 007700 05 Flight-Number Pic X(05) Value 'Fl#'. 007800 05 Class-Of-Travel Pic X(03) Value 'Cl'. 007900 05 City-Pair Pic X(09) Value 'C-Pair'. 008000 05 Mileage Pic X(09) Value 'Mileage'. 008100 05 Incbonus Pic X(10) Value 'Inc Bonus'. 008200 008300 01 List-Trailer. 008400 05 Pic X(25) 008500 Value 'Total Mileage '. 008600 05 Mileage Pic Z(11). 008700 05 Incbonus Pic Z(11). 008800 008900 01 List-Detail. 009000 05 Flight-Date Pic X(05). 009100 05 Pic X(02). 009200 05 Airline-Id Pic X(02). 009300 05 Pic X(02). 009400 05 Flight-Number Pic Z(04). 009500 05 Pic X(02). 009600 05 Class-Of-Travel Pic X(01). 009700 05 Pic X(02). 009800 05 City-Pair Pic X(07). 009900 05 Pic X(02). 010000 05 Mileage Pic Z(07). 010100 05 Pic X(04). 010200 05 Incbonus Pic Z(07). 010300 010400 77 MT-Freqmile Pic X(08) Value 'FREQMILE'. 010500 77 MT-Count Pic 9(03) Value 0. 010600 01 Tab-Search. 010700 05 TS-City-Pair. 010800 10 TS-Org-City Pic X(03). 010900 10 Pic X(01). 011000 10 TS-Dst-City Pic X(03). 011100 01 Mile-Table. 011200 05 City-Pair-Table Occurs 350 011300 Depending on MT-Count 011400 Ascending Key MT-City-Pair 011500 Indexed By Ndx. 011600 10 MT-City-Pair. 011700 15 MT-Org-City Pic X(03). 011800 15 Pic X(01). 011900 15 MT-Dst-Citu Pic X(03). 012000 10 Pic X(01). 012100 10 MT-Act-Miles Pic 9(05). 012200 012300 Linkage Section. 012400 01 Parameter. 012500 05 Parameter-Len Pic S9(04) Binary. 012600 05 Date-Pgm-Parm-Data Pic X(07). 012700 012800*--------------------------------------- 012900 Procedure Division Using Parameter. 013000*--------------------------------------- 013100 Display '==> FREQREAD is starting...' 013200 Perform Open-Files 013300 Perform Check-Parameter-Len 013400 Perform Call-Datepgm 013500 Perform Write-Freq-Header1 013600 Perform Write-Freq-Daterows 013700 Perform Write-Freq-Header2 013800 Perform Fill-Mile-Table 013900 Perform Read-Freqfile Until End-Of-Freq-File 014000 Perform Write-Freq-Trailer 014100 Perform Close-Files 014200 Display '==> FREQREAD ended normally' 014300 GoBack 014400 . 014500*------------------------------------- 014600 Check-Parameter-Len. 014700*------------------------------------- 014800 If Parameter-Len = 0 014900 Display '*** Parameter missing' 015000 Move 12 to Return-Code 015100 GoBack 015200 End-If 015300 . 015400*------------------------------------- 015500 Call-Datepgm. 015600*------------------------------------- 015700 Call Date-Pgm Using 015800 Date-Pgm-Parm-Data 015900 Date-Pgm-Parm-Status 016000 Date-Pgm-Date-Row1 016100 Date-Pgm-Date-Row2 016200 016300 If Parm-Error 016400 Display '*** Parameter ' 016500 Date-Pgm-Parm-Data 016600 ' is invalid' 016700 Move 8 to Return-Code 016800 GoBack 016900 End-If 017000 . 017100*------------------------------------- 017200 Read-Freqfile. 017300*------------------------------------- 017400 Read Freqfile 017500 At End 017600 Set End-Of-Freq-File to True 017700 Not At End 017800 Perform Write-Freq-Detail 017900 End-Read 018000 . 018100*------------------------------------- 018200 Calculate-Bonus. 018300*------------------------------------- 018400 Evaluate True 018500 When Mileage in File-Record Less Than 500 018600 Move 500 to Incbonus-Value 018700 Incbonus in List-Detail 018800 When Tourist 018900 Move Mileage in File-Record to 019000 Incbonus-Value 019100 Incbonus in List-Detail 019200 When Business 019300 Compute Incbonus-Value = 019400 Mileage in File-Record * 1.25 019500 Move Incbonus-Value to 019600 Incbonus in List-Detail 019700 When Firstclass 019800 Compute Incbonus-Value = 019900 Mileage in File-Record * 1.50 020000 Move Incbonus-Value to 020100 Incbonus in List-Detail 020200 End-Evaluate 020300 020400 Add Incbonus-Value to Incbonus-Total 020500 . 020600*------------------------------------- 020700 Search-City-Pair-Table. 020800*------------------------------------- 020900 Move City-Pair in File-Record 021000 to TS-City-Pair 021100 Search All City-Pair-Table 021200 At End 021300 Perform Search-Reverse-City-Pair 021400 When MT-City-Pair(Ndx) = TS-City-Pair 021500 Move MT-Act-Miles(Ndx) to 021600 Mileage in List-Detail 021700 End-Search 021800 . 021900*------------------------------------- 022000 Search-Reverse-City-Pair. 022100*------------------------------------- 022200 Move Origin in File-Record to 022300 TS-Dst-City 022400 Move Dest in File-Record to 022500 TS-Org-City 022600 Search All City-Pair-Table 022700 At End 022800 Display 'Hittar inte City-Pair: ' 022900 TS-City-Pair 023000 Move 99 to Return-Code 023100 GoBack 023200 When MT-City-Pair(Ndx) = TS-City-Pair 023300 Move MT-Act-Miles(Ndx) to 023400 Mileage in List-Detail 023500 End-Search 023600 . 023700*------------------------------------- 023800 Fill-Mile-Table. 023900*------------------------------------- 024000 Call MT-Freqmile Using Mile-Table, MT-Count 024100 . 024200*------------------------------------- 024300 Write-Freq-Daterows. 024400*------------------------------------- 024500 Write Listrow from Date-Row1 024600 Write Listrow from Date-Row2 024700 Write Listrow from List-Blankrow 024800 . 024900*------------------------------------- 025000 Write-Freq-Header1. 025100*------------------------------------- 025200 Write Listrow from List-Header1 025300 Write Listrow from List-Blankrow 025400 . 025500*------------------------------------- 025600 Write-Freq-Header2. 025700*------------------------------------- 025800 Write Listrow from List-Header2 025900 Write Listrow from List-Blankrow 026000 . 026100*------------------------------------- 026200 Write-Freq-Trailer. 026300*------------------------------------- 026400 Write Listrow from List-Blankrow 026500 Move Mileage-Total to 026600 Mileage in List-Trailer 026700 Move Incbonus-Total to 026800 Incbonus in List-Trailer 026900 Write Listrow from List-Trailer 027000 . 027100*------------------------------------- 027200 Write-Freq-Detail. 027300*------------------------------------- 027400 Perform Search-City-Pair-Table 027500 Perform Calculate-Bonus 027600 Move Corr File-Record to List-Detail 027700 Add Mileage in File-Record to 027800 Mileage-Total 027900 028000 Write Listrow from List-Detail 028100 . 028200*------------------------------------- 028300 Open-Files. 028400*------------------------------------- 028500 Open Input FREQFILE 028600 If Freqfile-Openerror 028700 Display '==> Openerror: FREQFILE' 028800 Display '==> Status : ' Freqfile-Status 028900 Move 21 to Return-Code 029000 Goback 029100 End-If 029200 Display '==> FREQFILE is Open' 029300 029400 Open Output FREQLIST 029500 If Freqlist-Openerror 029600 Display '==> Openerror: FREQLIST' 029700 Display '==> Status : ' Freqlist-Status 029800 Move 23 to Return-Code 029900 Goback 030000 End-If 030100 Display '==> FREQLIST is Open' 030200 . 030300*------------------------------------- 030400 Close-Files. 030500*------------------------------------- 030600 Close FREQFILE 030700 FREQLIST 030800 . 030900 End Program FREQPGM5. 031000