000100 Identification Division. 000200 Program-ID. VIDEOSR1. 000300 000400 Environment Division. 000500 Configuration Section. 000600 Special-Names. 000700 Decimal-Point is Comma. 000800 000900 Input-Output Section. 001000 File-Control. 001100 001200 Select Video-Titles-File Assign to VIDETIT 001300 Organization is Indexed 001400* File Status is VTF-Status 001500 Access Mode is Dynamic 001600 Record Key is VTF-Video-Code 001700 Alternate Record key is VTF-Supplier-code 001800 with Duplicates 001900 . 002000 Select Video-Rentals-File Assign to VIDEREN 002100 Organization is Indexed 002200 File Status is VRF-Status 002300 Access Mode is Dynamic 002400 Record Key is VRF-Video-Num 002500 Alternate Record Key is VRF-Video-Code 002600 with Duplicates 002700 . 002800 002900 Select Video-Supplier-File Assign to VIDESUP 003000 Organization is Relative 003100* File Status is VSF-Status 003200 Access Mode is Random 003300 Relative Key is Supplier-Key 003400 . 003500 003600 Select Video-Report-File Assign to VIDERPT 003700 . 003800 Data Division. 003900 File Section. 004000 004100 FD Video-Titles-File. 004200 01 VTF-Record. 004300 05 VTF-Video-Code Pic X(05). 004400 05 VTF-Video-Title Pic X(30). 004500 05 VTF-Supplier-Code Pic X(02). 004600 05 Pic X(43). 004700 004800 FD Video-Rentals-File. 004900 01 VRF-Record. 005000 05 VRF-Video-Num Pic X(05). 005100 05 VRF-Video-Code Pic X(05). 005200 05 VRF-Rental-Earnings Pic 9(04)V99. 005300 05 VRF-Purchase-Earnings Pic 9(03)V99. 005400 05 Pic X(59). 005500 005600 FD Video-Supplier-File. 005700 01 VSF-Record. 005800 05 VSF-Supplier-Code Pic X(02). 005900 05 VSF-Supplier-Name Pic X(20). 006000 05 VSF-Supplier-Address Pic X(58). 006100 006200 FD Video-Report-File. 006300 01 VRF-Print-Line Pic X(80). 006400 006500 006600 Working-Storage Section. 006700 77 Video-Count Pic 9(02) Value 0. 006800 77 Supplier-Key Pic 9(02). 006900 77 Old-Supplier-Code Pic 9(02). 007000 007100 01 File-Status-Fields. 007200 05 VRF-Status Pic X(02). 007300 05 VTF-Status Pic X(02). 007400 05 VSF-Status Pic X(02). 007500 007600 01 End-Of-File-Flags. 007700 05 Filler Pic 9(01) Value 0. 007800 88 VTF-EOF Value 1. 007900 05 Filler Pic 9(01) Value 0. 008000 88 Not-VRF-EOF Value 0. 008100 88 VRF-EOF Value 1. 008200 008300 Procedure Division. 008400 Perform Open-All-Files 008500 Move Zeros to VTF-Supplier-Code 008600 Start Video-Titles-File 008700 Key Is Greater Than VTF-Supplier-Code 008800 Invalid Key 008900 Display 'Error on START VTF, status: ' VTF-Status 009000 Move 99 to Return-Code 009100 GoBack 009200 Not Invalid Key 009300 Read Video-Titles-File NEXT Record 009400 At End 009500 Set VTF-EOF to True 009510 Not At End 009520 Display '+++ Supplier: ' 009521 VTF-Supplier-Code 009530 Display Space 009540 Display '*** New Video Code : ' 009541 VTF-Video-Code 009550 Perform Read-Video-Rentals-File 009560 Until VTF-EOF 009600 End-Read 009700 End-Start 010200 010300 GoBack 010400 . 010500 010600 Read-Video-Rentals-File. 010700 Move VTF-Supplier-Code to Old-Supplier-Code 010800 Move VTF-Video-Code to VRF-Video-Code 010900 011000 Read Video-Rentals-File Key is VRF-Video-Code 011100 Invalid Key 011200 Display '*** No Rentals for: ' VTF-Video-Code 011300 Not Invalid Key 011400 Display '*** Rental(1): ' VRF-Video-Code ' , ' 011500 VRF-Rental-Earnings ', ' VTF-Video-Title 011600 Add 1 to Video-Count 011700 End-Read 011800 Set Not-VRF-EOF to True 011900 012000 Perform Until VRF-Video-Code Not Equal VTF-Video-Code 012100 Or VRF-EOF 012200 Read Video-Rentals-File Next Record 012300 At End 012400 Set VRF-EOF to True 012500 Not AT End 012600 If VRF-Video-Code = VTF-Video-Code 012700 Display '*** Rental(Next): ' 012800 VRF-Video-Code ' , ' 012900 VRF-Rental-Earnings ', ' 013000 VTF-Video-Title 013100 Add 1 to Video-Count 013200 End-If 013300 End-Read 013400 End-Perform 013500 Display ' *** No more rentals for Video Title' 013600 013700 Perform Sum-Title-Earnings 013800 013900 Read Video-Titles-File Next Record 014000 At End 014100 Set VTF-EOF to True 014200 Perform Sum-Supplier-Earnings 014300 Not At End 014400 If VTF-Supplier-Code Not Equal Old-Supplier-Code 014500 Perform Sum-Supplier-Earnings 014600 Move VTF-Supplier-Code to Old-Supplier-Code 014700 Display '+++ Supplier: ' VTF-Supplier-Code 014800 End-If 014900 Display Space 015000 Display '*** New Video Code : ' VTF-Video-Code 015100 End-Read 015200 . 015300 Sum-Title-Earnings. 015400 Display '*** Number of Videos: ' Video-Count 015500 Display '=== Sum-Title-Earnings for title: ' VTF-Video-Title 015600 Move Zero to Video-Count 015700 . 015800 Sum-Supplier-Earnings. 015900 Display Space 016000 Display '+++++ Sum-Supplier-Earnings: ' 016100 Old-Supplier-Code 016200 Display '---------------------------------------------' 016300 . 016400 Open-All-Files. 016500 Open Input Video-Rentals-File 016600 Open Input Video-Titles-File 016700 Open Input Video-Supplier-File 016800 Open Output Video-Report-File 016900 . 017000 Close-All-Files. 017100 Close Video-Rentals-File, 017200 Video-Titles-File, 017300 Video-Supplier-File, 017400 Video-Report-File 017500 . 017600 End Program VIDEOSR1.