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