000100 Identification Division. 000200 Program-Id. FREQPGM7. 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 FREQLINE Assign to FREQADD 001300 Organization is Indexed 001400 Access is Sequential 001500 Record Key is Airline-Id in Line-Record 001600 File Status is Freqline-Status 001700 . 001800 Select FREQDATE Assign to FREQDDD 001900 Organization is Sequential 002000 Access is Sequential 002100 File Status is Freqdate-Status 002200 . 002300 Select FREQLIST Assign to FREQLDD 002400 Organization is Sequential 002500 Access is Sequential 002600 File Status is Freqlist-Status 002700 . 002800 Data Division. 002900 File Section. 003000 FD FREQFILE. 003100 01 File-Record. 003200 88 End-Of-Freq-File Value High-Value. 003300 05 Pic X(01). 003400 05 Flight-Date Pic X(05). 003500 05 City-Pair. 003600 10 Origin Pic X(03). 003700 10 Pic X(01). 003800 10 Dest Pic X(03). 003900 05 Airline-Id Pic X(02). 004000 05 Flight-Number Pic 9(04). 004100 05 Class-Of-Travel Pic X(01). 004200 88 Tourist Value 'Y'. 004300 88 Business Value 'C'. 004400 88 Firstclass Value 'F'. 004500 05 Mileage Pic 9(05). 004600 05 Pic X(55). 004700 004800 FD FREQDATE Recording mode F. 004900 01 Date-Record. 005100 05 Search-Date-Start Pic 9(04). 005200 05 Pic X(01). 005300 88 OK-Date-Sep Value '-'. 005400 05 Search-Date-End Pic 9(04). 005500 05 Pic X(71). 005600 005700 FD FREQLINE. 005800 01 Line-Record. 005900 05 Airline-Id Pic X(02). 006000 05 Airline-Name Pic X(25). 006100 05 Pic X(53). 006200 006300 FD FREQLIST Recording mode F. 006400 01 Listrow Pic X(120). 006500 006600*--------------------------------------- 006700 Working-Storage Section. 006800*--------------------------------------- 006900 007000 77 Mileage-Total Pic 9(08) Value 0. 007100 77 Incbonus-Value Pic 9(08) Value 0. 007200 77 Incbonus-Total Pic 9(08) Value 0. 007300 007400 01 Freqfile-Status Pic X(02). 007500 88 Freqfile-Openerror Values '01' thru '99'. 007510 007600 01 Freqmile-Status Pic X(02). 007700 88 Freqmile-Openerror Values '01' thru '99'. 007710 007800 01 Freqline-Status Pic X(02). 007810 007900 88 Freqline-Openerror Values '01' thru '99'. 007910 008000 01 Freqdate-Status Pic X(02). 008100 88 Search-Date-File Values '00'. 008200 88 No-Search-Date-File Values '01' thru '97'. 008201 88 Search-Date-Record Value '98'. 008202 88 No-Search-Date-Record Value '99'. 008210 008300 01 Freqlist-Status Pic X(02). 008400 88 Freqlist-Openerror Values '01' thru '99'. 008500 008600 01 Date-Row1. 008700 05 Pic X(20) Value 'Printed :'. 008800 05 Date-Pgm-Date-Row1 Pic X(50) Value Space. 008900 009000 01 Date-Row2. 009100 05 Pic X(20) Value 'Valid Until :'. 009200 05 Date-Pgm-Date-Row2 Pic X(50) Value Space. 009300 009400 01 Date-Row3. 009500 05 Pic X(20) Value 'Search Interval:'. 009600 05 DR1-Start Pic X(05). 009700 05 Pic X(03) Value ' - '. 009800 05 DR1-End Pic X(05). 009900 010000 77 Date-Pgm Pic X(08) Value 'FREQDATE'. 010100 77 Date-Pgm-Parm-Status Pic 9. 010200 88 Parm-Error Value 0. 010300 88 Parm-OK Value 1. 010400 010500 01 List-Blankrow. 010600 05 Pic X(120) Value Spaces. 010700 010800 01 List-Header1. 010900 05 Pic X(35) Value 'Frequent Flyer Report'. 011000 011100 01 List-Header2. 011200 05 Flight-Date Pic X(07) Value 'Date'. 011300 05 Airline-Name Pic X(27) Value 'Airline-Name'. 011400 05 Flight-Number Pic X(06) Value 'Flnr'. 011500 05 Class-Of-Travel Pic X(03) Value 'Cl'. 011600 05 City-Pair Pic X(10) Value 'C-Pair'. 011700 05 Mileage Pic X(11) Value 'Mileage'. 011800 05 Incbonus Pic X(11) Value 'Inc Bonus'. 011900 012000 01 List-Trailer. 012100 05 Pic X(48) 012200 Value 'Total Mileage '. 012300 05 Mileage Pic Z(11). 012400 05 Incbonus Pic Z(11). 012500 012600 01 List-Detail. 012700 05 Flight-Date Pic X(05). 012800 05 Pic X(01). 012900 05 Airline-Name Pic X(25). 013000 05 Pic X(03). 013100 05 Flight-Number Pic Z(04). 013200 05 Pic X(02). 013300 05 Class-Of-Travel Pic X(01). 013400 05 Pic X(02). 013500 05 City-Pair Pic X(07). 013600 05 Pic X(02). 013700 05 Mileage Pic Z(07). 013800 05 Pic X(04). 013900 05 Incbonus Pic Z(07). 014000 05 Pic X(04). 014100 014200 77 MT-Freqmile Pic X(08) Value 'FREQMILE'. 014300 77 MT-Count Pic 9(03) Value 0. 014400 01 Tab-Search. 014500 05 TS-City-Pair. 014600 10 TS-Org-City Pic X(03). 014700 10 Pic X(01). 014800 10 TS-Dst-City Pic X(03). 014900 01 Mile-Table. 015000 05 City-Pair-Table Occurs 350 015100 Depending on MT-Count 015200 Ascending Key MT-City-Pair 015300 Indexed By Ndx. 015400 10 MT-City-Pair. 015500 15 MT-Org-City Pic X(03). 015600 15 Pic X(01). 015700 15 MT-Dst-Citu Pic X(03). 015800 10 Pic X(01). 015900 10 MT-Act-Miles Pic 9(05). 016000 016100 01 Pic 9 Value 0. 016200 88 Readend Value 1. 016300 88 Lineend Value 2. 016400 016500 77 Line-Table-Rows Pic 99 Value 1. 016600 01 Tables. 016700 05 Line-Table Occurs 25 Times 016800 Depending on Line-Table-Rows 016900 Ascending 017000 Key is Line-Table-Airline-Id 017100 Indexed by Lineindex. 017200 10 Line-Table-Airline-Id Pic X(02). 017300 10 Line-Table-Airline-Name Pic X(25). 017400 017500 01 WS-Fligth-Date. 017600 05 FD-Start Pic XX/XX. 017700 05 FD-End Pic XX/XX. 017800 017900 018000 Linkage Section. 018100 01 Parameter. 018200 05 Parameter-Len Pic S9(04) Binary. 018300 05 Date-Pgm-Parm-Data Pic X(07). 018400 018500*--------------------------------------- 018600 Procedure Division Using Parameter. 018700*--------------------------------------- 018800 Display '==> FREQREAD is starting...' 018900 Perform Open-Files 019000 Perform Check-Parameter-Len 019100 Perform Read-Date-Record 019200 Perform Call-Datepgm 019300 Perform Fill-Line-Table 019400 Perform Fill-Mile-Table 019500 Perform Write-Freq-Header1 019600 Perform Write-Freq-Daterows 019700 Perform Write-Freq-Header2 019800 Perform Read-Freqfile Until End-Of-Freq-File 019900 Perform Write-Freq-Trailer 020000 Perform Close-Files 020100 Display '==> FREQREAD ended normally' 020200 GoBack 020300 . 020400*------------------------------------- 020500 Check-Parameter-Len. 020600*------------------------------------- 020700 If Parameter-Len = 0 020800 Display '*** Parameter missing' 020900 Move 12 to Return-Code 021000 GoBack 021100 End-If 021200 . 021300*------------------------------------- 021400 Read-Date-Record. 021500*------------------------------------- 021600 If Search-Date-File 021700 Read Freqdate 021800 At End 021900 Set No-Search-Date-Record to True 021910 Move '*' to DR1-Start DR1-End 022000 Not At end 022100 Evaluate True 022200 When Not OK-Date-Sep 022300 Display '*** Parameter format incorrect' 022400 Display '*** Must be ddmm-ddmm' 022500 Move 99 to Return-Code 022600 GoBack 022700 When Search-Date-Start(1:2) > 12 or 022800 Search-Date-Start(3:2) > 31 022900 Display '*** Invalid Search-Date-Start value' 022910 Display '*** ' Search-Date-Start 023000 Move 98 to Return-Code 023100 GoBack 023110 When Search-Date-End(1:2) > 12 or 023120 Search-Date-End(3:2) > 31 023130 Display '*** Invalid Search-Date-End value' 023140 Move 98 to Return-Code 023141 Display '*** ' Search-Date-End 023150 GoBack 023200 When Other 023300 Move Search-Date-Start to FD-Start 023400 Move Search-Date-End to FD-End 023500 Move FD-Start to DR1-Start 023600 Move FD-End to DR1-End 023610 Set Search-Date-Record to True 023700 End-Evaluate 023800 End-Read 023900 Else 024000 Set No-Search-Date-Record to True 024010 Move '*' to DR1-Start DR1-End 024100 End-If 024200 . 024300*------------------------------------- 024400 Call-Datepgm. 024500*------------------------------------- 024600 Call Date-Pgm Using 024700 Date-Pgm-Parm-Data 024800 Date-Pgm-Parm-Status 024900 Date-Pgm-Date-Row1 025000 Date-Pgm-Date-Row2 025100 025200 If Parm-Error 025300 Display '*** Parameter ' 025400 Date-Pgm-Parm-Data 025500 ' is invalid' 025600 Move 8 to Return-Code 025700 GoBack 025800 End-If 025900 . 026000*------------------------------------- 026100 Read-Freqfile. 026200*------------------------------------- 026300 Read Freqfile 026400 At End 026500 Set End-Of-Freq-File to True 026600 Not At End 026700 If Search-Date-Record 027300 027400 If (FD-Start <= Flight-Date in File-Record) 027500 And 027600 (FD-End >= Flight-Date in File-Record) 027700 Perform Write-Freq-Detail 027800 End-If 027900 End-If 028000 End-Read 028100 . 028200*------------------------------------- 028300 Calculate-Bonus. 028400*------------------------------------- 028500 Evaluate True 028600 When Mileage in File-Record Less Than 500 028700 Move 500 to Incbonus-Value 028800 Incbonus in List-Detail 028900 When Tourist 029000 Move Mileage in File-Record to 029100 Incbonus-Value 029200 Incbonus in List-Detail 029300 When Business 029400 Compute Incbonus-Value = 029500 Mileage in File-Record * 1.25 029600 Move Incbonus-Value to 029700 Incbonus in List-Detail 029800 When Firstclass 029900 Compute Incbonus-Value = 030000 Mileage in File-Record * 1.50 030100 Move Incbonus-Value to 030200 Incbonus in List-Detail 030300 End-Evaluate 030400 030500 Add Incbonus-Value to Incbonus-Total 030600 . 030700*------------------------------------- 030800 Search-City-Pair-Table. 030900*------------------------------------- 031000 Move City-Pair in File-Record 031100 to TS-City-Pair 031200 Search All City-Pair-Table 031300 At End 031400 Perform Search-Reverse-City-Pair 031500 When MT-City-Pair(Ndx) = TS-City-Pair 031600 Move MT-Act-Miles(Ndx) to 031700 Mileage in List-Detail 031800 End-Search 031900 . 032000*------------------------------------- 032100 Search-Reverse-City-Pair. 032200*------------------------------------- 032300 Move Origin in File-Record to 032400 TS-Dst-City 032500 Move Dest in File-Record to 032600 TS-Org-City 032700 Search All City-Pair-Table 032800 At End 032900 Display 'Hittar inte City-Pair: ' 033000 TS-City-Pair 033100 Move 99 to Return-Code 033200 GoBack 033300 When MT-City-Pair(Ndx) = TS-City-Pair 033400 Move MT-Act-Miles(Ndx) to 033500 Mileage in List-Detail 033600 End-Search 033700 . 033800*------------------------------------- 033900 Fill-Mile-Table. 034000*------------------------------------- 034100 Call MT-Freqmile Using Mile-Table, MT-Count 034200 . 034300*------------------------------------- 034400 Fill-Line-Table. 034500*------------------------------------- 034600 Perform Until Lineend 034700 Read Freqline 034800 At End 034900 Set Lineend to True 035000 Not At End 035100 Move Airline-Id in Line-Record to 035200 Line-Table-Airline-Id(Line-Table-Rows) 035300 Move Airline-Name in Line-Record to 035400 Line-Table-Airline-Name(Line-Table-Rows) 035500 Add 1 to Line-Table-Rows 035600 End-Read 035700 End-Perform 035800 . 035900*------------------------------------- 036000 Search-Line-Table. 036100*------------------------------------- 036200 Search All Line-Table 036300 At End 036400 Move '*** N/A ***' to 036500 Airline-Name in List-Detail 036600 When Line-Table-Airline-Id(Lineindex) = 036700 Airline-Id in File-Record 036800 Move Line-Table-Airline-Name(Lineindex) to 036900 Airline-Name in List-Detail 037000 037100 End-Search 037200 . 037300*------------------------------------- 037400 Write-Freq-Daterows. 037500*------------------------------------- 037600 Write Listrow from Date-Row1 037700 Write Listrow from Date-Row2 037800 Write Listrow from List-Blankrow 037900 Write Listrow from Date-Row3 038000 Write Listrow from List-Blankrow 038100 . 038200*------------------------------------- 038300 Write-Freq-Header1. 038400*------------------------------------- 038500 Write Listrow from List-Header1 038600 Write Listrow from List-Blankrow 038700 . 038800*------------------------------------- 038900 Write-Freq-Header2. 039000*------------------------------------- 039100 Write Listrow from List-Header2 039200 Write Listrow from List-Blankrow 039300 . 039400*------------------------------------- 039500 Write-Freq-Trailer. 039600*------------------------------------- 039700 Write Listrow from List-Blankrow 039800 Move Mileage-Total to 039900 Mileage in List-Trailer 040000 Move Incbonus-Total to 040100 Incbonus in List-Trailer 040200 Write Listrow from List-Trailer 040300 . 040400*------------------------------------- 040500 Write-Freq-Detail. 040600*------------------------------------- 040700 Perform Search-City-Pair-Table 040800 Perform Search-Line-Table 040900 Perform Calculate-Bonus 041000 Move Corr File-Record to List-Detail 041100 Add Mileage in File-Record to 041200 Mileage-Total 041300 041400 Write Listrow from List-Detail 041500 . 041600*------------------------------------- 041700 Open-Files. 041800*------------------------------------- 041900 Open Input FREQFILE 042000 If Freqfile-Openerror 042100 Display '==> Openerror: FREQFILE' 042200 Display '==> Status : ' Freqfile-Status 042300 Move 21 to Return-Code 042400 Goback 042500 End-If 042600 Display '==> FREQFILE is Open' 042700 042800 Open Input FREQLINE 042900 If Freqline-Openerror 043000 Display '==> Openerror: FREQLINE' 043100 Display '==> Status : ' Freqline-Status 043200 Move 21 to Return-Code 043300 Goback 043400 End-If 043500 Display '==> FREQLINE is Open' 043600 043700 Open Input FREQDATE 043800 If No-Search-Date-File 043900 Display '==> No Date File, full report' 044000 Else 044100 Display '==> FREQDATE is Open' 044200 End-If 044300 044400 Open Output FREQLIST 044500 If Freqlist-Openerror 044600 Display '==> Openerror: FREQLIST' 044700 Display '==> Status : ' Freqlist-Status 044800 Move 23 to Return-Code 044900 Goback 045000 End-If 045100 Display '==> FREQLIST is Open' 045200 . 045300*------------------------------------- 045400 Close-Files. 045500*------------------------------------- 045600 Close FREQFILE 045700 FREQLINE 045800 FREQLIST 045900 . 046000 End Program FREQPGM7. 046100