000100 Identification Division. 000200 Program-ID. AROMA2C. 000300*--------------------------------------------------- 000400* Programmet skapar en detaljerad försäljningsrapport 000500* för en enskild kund. 000600* Kundnummer anges som exekveringsparameter 000700*--------------------------------------------------- 000800 000900 Environment Division. 001000 Configuration Section. 001100 Special-Names. 001200 Decimal-Point is Comma. 001300 001400 Input-Output Section. 001500 File-Control. 001600 Select Sales-File Assign to AROMA2S 001700 Organization is Sequential 001800 . 001900 Select Customer-File Assign to AROMA2C 002000 Organization is Indexed 002100 Access is Random 002200 Record Key is CF-Cust-ID 002300 . 002400 Select Oils-File Assign to AROMA2O 002500 Organization is Indexed 002600 Access is Dynamic 002700 Record Key is OF-Oil-Id 002800 . 002900 Select Work-File Assign to AROMA2W 003000 . 003100 Select Summary-Report Assign to AROMA2R 003200 Organization is Sequential 003300 . 003400 Data Division. 003500 File Section. 003600 FD Sales-File Recording Mode F. 003700 01 Sales-Rec. 003800 88 End-Of-Sales-File Value High-Values. 003900 05 SF-Cust-Id Pic X(05). 004000 05 SF-Oil-Id. 004100 10 SF-Oil-Type Pic X(01). 004200 88 Essential-Oil Value 'E'. 004300 88 Basic-Oil Value 'B'. 004400 10 SF-Oil-Nr Pic X(02). 004500 05 SF-Unit-Size Pic 9. 004600 05 SF-Units-Sold Pic 999. 004700 05 Filler Pic X(68). 004800 004900 FD Customer-File. 005000 01 Customer-Rec. 005100 88 End-Of-Customer-File Value High-Values. 005200 05 CF-Cust-ID Pic X(5). 005300 05 CF-Cust-Name Pic X(20). 005400 05 CF-Cust-Address Pic X(30). 005500 05 Filler Pic X(25). 005600 005700 FD Oils-File. 005800 01 Oils-Rec. 005900 88 End-Of-Oil-File Value High-Values. 006000 05 OF-Oil-Id Pic X(03). 006100 05 OF-Oil-Name Pic X(20). 006200 05 OF-Cost-Per-Mls Pic 99V99. 006300 05 Filler Pic X(53). 006400 006500 SD Work-File. 006600 01 Work-Rec. 006700 88 End-Of-Work-File Value High-Values. 006800 05 WF-Cust-Id Pic X(05). 006900 05 WF-Oil-Id Pic X(03). 007000 05 WF-Unit-Size Pic 9. 007100 05 WF-Units-Sold Pic 999. 007200 05 Filler Pic X(78). 007300 007400 FD Summary-Report Recording Mode F. 007500 01 Print-Line Pic X(79). 007600 007700 Working-Storage Section. 007800 007900 01 Customer-Report-Heading-Line. 008000 05 Pic X(15) Value Space. 008100 05 Pic X(35) Value 'Aromamora Summary Sales Report'. 008200 008300 01 Report-Heading-Underline. 008400 05 Pic X(15) Value Spaces. 008500 05 Pic X(32) Value All '-'. 008600 008700 01 Report-Heading-Allspaces. 008800 05 Pic X(50) Value Spaces. 008900 009000 01 Customer-Line1. 009100 05 Pic X(15) Value 'Customer Name'. 009200 05 Cl-Cust-Name Pic X(25). 009300 009400 01 Customer-Line2. 009500 05 Pic X(15) Value 'Customer Num'. 009600 05 Cl-Cust-Id Pic X(05). 009700 009800 01 Customer-Line3. 009900 05 Pic X(15) Value 'Print-date'. 010000 05 Cl-Print-Date Pic X(50). 010100 010200 01 Customer-Oils-Detail-Header. 010300 05 Pic X(22) Value 'Oil-Name'. 010400 05 Pic X(05) Value 'Id'. 010500 05 Pic X(07) Value 'Units'. 010600 05 Pic X(05) Value 'Size'. 010700 05 Pic X(07) Value 'PerMls'. 010800 05 Pic X(07) Value Space. 010900 05 Pic X(05) Value 'Total'. 011000 011100 01 Customer-Oils-Detail. 011200 05 Prn-Oil-Name Pic X(22). 011300 05 Prn-Oil-Id Pic X(05). 011400 05 Prn-Oil-Units Pic X(07). 011500 05 Prn-Oil-Unit-Size Pic X(05). 011600 05 Prn-Oil-Price-Per-Mls Pic ZZ9,99. 011700 05 Pic X(04) Value Space. 011800 05 Prn-Oil-Price-Total Pic ZZZZZ9,99. 011900 012000 01 Customer-Oils-Summary. 012100 05 Pic X(24) Value 'S u m m a r y'. 012200 05 Prn-Total-Oil-Units-Sold Pic Z(06). 012300 05 Pic X(19) Value Space. 012400 05 Prn-Report-Oil-Price-Total Pic Z(05)9,99. 012500 012600 01 Summary-Counters. 012700 05 Oil-Price-Total Pic 9(06)V99. 012800 05 Report-Oil-Price-Total Pic 9(06)V99 Value 0. 012900 05 Total-Oil-Units-Sold Pic 9(06) Value 0. 013000 013100 77 Datepgm Pic X(08) Value 'FREQDATE'. 013200 01 Dateparam. 013300 05 Date-Type Pic X(07) Value 'DATUM=X'. 013400 05 Date-Status Pic 9 Value 9. 013500 05 Date-Date1 Pic X(50). 013600 05 Date-Date2 Pic X(50). 013700 013800 Linkage Section. 013900 01 Exec-Parameter. 014000 05 Param-Len Pic S9(04) Binary. 014100 05 Param-Cust-Id Pic X(05). 014200 014300 Procedure Division Using Exec-Parameter. 014400 Open Input Customer-File 014500 014600 Perform Check-Parameter-Input 014700 014800 If Return-Code Not = 0 014900 Display '==>> Program halted due to severe error' 015000 Display '==>> Return-Code ' Return-Code 015100 Stop Run 015200 End-If 015300 015400 Open Input Sales-File 015500 Open Input Oils-File 015600 Open Input Customer-File 015700 Open Output Summary-Report 015800 015900 Sort Work-File On Ascending WF-Cust-Id 016000 Input Procedure Select-Customer 016100 Output Procedure Print-Customer-Summary-Report 016200 016300 If Sort-Return Not = 0 016400 Display 'Sort-Return-Code ' Sort-Return 016500 Move 99 to Return-Code 016600 End-If 016700 016800 Close Sales-File 016900 Close Oils-File 017000 Close Customer-File 017100 Close Summary-Report 017200 017300 GoBack 017400 . 017500 Check-Parameter-Input. 017600 Evaluate True 017700 When Param-Len = 0 017800 Display '==>> Parameter missing' 017900 Move 99 to Return-Code 018000 When Param-Len < 5 018100 Display '==>> Parameter must be 5 digits' 018200 Move 88 to Return-Code 018300 When Param-Cust-Id is Not Numeric 018400 Display '==>> Parameter not numeric' 018500 Move 77 to Return-Code 018600 When Other 018700 Move Param-Cust-Id to CF-Cust-Id 018800 Read Customer-File 018900 Invalid Key 019000 Display '==>> Customer number ' CF-Cust-ID 019100 ' is missing in Customer-File' 019200 Move 66 to Return-Code 019300 End-Read 019400 End-Evaluate 019500 . 019600 019700 Select-Customer. 019800 Perform Read-Sales-File 019900 020000 Perform Until End-Of-Sales-File 020100 If SF-Cust-Id = Param-Cust-Id 020200 Release Work-Rec From Sales-Rec 020300 End-If 020400 Perform Read-Sales-File 020500 End-Perform 020600 . 020700 020800 Read-Sales-File. 020900 Read Sales-File 021000 At End 021100 Set End-Of-Sales-File to True 021200 Not At End 021300 Display '*** Sales-Rec: ' Sales-Rec(1:20) 021400 End-Read 021500 . 021600 021700 Print-Customer-Summary-Report. 021800 021900 Perform Write-Header-Lines 022000 022100 Perform Return-Work-File 022200 022300 Perform Until End-Of-Work-File 022400 Perform Create-Customer-Oils-Detail 022500 Write Print-Line 022600 From Customer-Oils-Detail 022700 After Advancing 1 Lines 022800 Perform Return-Work-File 022900 End-Perform 023000 023100 Move Total-Oil-Units-Sold to 023200 Prn-Total-Oil-Units-Sold 023300 Move Report-Oil-Price-Total to 023400 Prn-Report-Oil-Price-Total 023500 Write Print-Line 023600 From Report-Heading-Allspaces 023700 After Advancing 1 Lines 023800 Write Print-Line 023900 From Customer-Oils-Summary 024000 After Advancing 1 Lines 024100 . 024200 024300 Return-Work-File. 024400 Return Work-File 024500 At End 024600 Set End-Of-Work-File to True 024700 End-Return 024800 . 024900 025000 Create-Customer-Oils-Detail. 025100 Move WF-Oil-Id to OF-Oil-Id 025200 025300 Read Oils-File 025400 Invalid Key 025500 Display 'Oil-Id ' OF-Oil-Id 025600 ' is missing in Oils-File' 025700 Move 98 to Return-Code 025800 Stop Run 025900 End-Read 026000 026100 Move OF-Oil-Name to Prn-Oil-Name 026200 Move OF-Oil-Id to Prn-Oil-Id 026300 Move WF-Unit-Size to Prn-Oil-Unit-Size 026400 Move WF-Units-Sold to Prn-Oil-Units 026500 Move OF-Cost-Per-Mls to Prn-Oil-Price-Per-Mls 026600 026700 Compute Oil-Price-Total = WF-Units-Sold * 026800 WF-Unit-Size * OF-Cost-Per-Mls 026900 027000 Add Oil-Price-Total to Report-Oil-Price-Total 027100 Move Oil-Price-Total to Prn-Oil-Price-Total 027200 Add WF-Units-Sold to Total-Oil-Units-Sold 027300 . 027400 027500 Write-Header-Lines. 027600 Perform Read-Customer-File 027700 027800 Call Datepgm Using Date-Type, Date-Status, 027900 Date-Date1, Date-Date2 028000 Move Date-Date1 to Cl-Print-Date 028100 028200 Write Print-Line 028300 From Customer-Line1 028400 After Advancing 1 Line 028500 Write Print-Line 028600 From Customer-Line2 028700 After Advancing 1 Line 028800 Write Print-Line 028900 From Customer-Line3 029000 After Advancing 1 Line 029100 Write Print-Line 029200 From Report-Heading-AllSpaces 029300 After Advancing 1 Line 029400 Write Print-Line 029500 From Customer-Oils-Detail-Header 029600 After Advancing 3 Lines 029700 . 029800 029900 Read-Customer-File. 030000 Move Param-Cust-Id to CF-Cust-Id 030100 Read Customer-File 030200 Invalid Key 030300 Display 'Cust-Id ' Param-Cust-Id 030400 ' is missing in Customer-File' 030500 Move 99 to Return-Code 030600 Stop Run 030700 Not Invalid Key 030800 Move CF-Cust-Name to CL-Cust-Name 030900 Move CF-Cust-Id to CL-Cust-Id 031000 End-Read 031100 . 031200 031300 End Program AROMA2C.