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