000100 Identification Division. 000200 Program-Id. AROMA3B. 000300 Environment Division. 000400 Configuration Section. 000500 Special-Names. 000600 Decimal-Point is Comma 000700 . 000800 Input-Output Section. 000900 File-Control. 001000 Select Oil-Details-File Assign to AROMODF 001100 Organization is Indexed 001200 Access is Dynamic 001300 Record Key is Oil-Num-ODF 001400 Alternate Record Key is Oil-Name-ODF 001500 With Duplicates 001600 File Status is ODF-Status 001700 . 001800 001900 Select Oil-Stock-File Assign to AROMAOSF 002000 Organization is Relative 002100 Access mode is Dynamic 002200 Relative Key is WS-Rel-Rec-Num 002300 File Status is OSF-Status 002400 . 002500 002600 Select Trans-File Assign to AROMATRX 002700 Organization is Sequential 002800 . 002900 003000 Select Report-File Assign to AROMARPT 003100 Organization is Sequential 003200 . 003300 003400 Select Error-File Assign to AROMAERR 003500 Organization is Sequential 003600 . 003700 003800 Data Division. 003900 File Section. 004000 FD Oil-Details-File Global. 004100 01 ODF-Rec. 004200 88 End-Of-ODF Value High-Value. 004300 05 Oil-Num-ODF Pic X(04). 004400 05 Oil-Name-ODF Pic X(20). 004500 05 Unit-Size-ODF Pic 9(02). 004600 05 Unit-Cost-ODF Pic 99V99. 004700 05 Pic X(50). 004800 004900 FD Oil-Stock-File Global. 005000 01 OSF-Rec. 005100 05 Oil-Num-OSF Pic 9(04). 005200 05 Qty-In-Stock-OSF Pic 9(05). 005300 05 Pic X(01). 005400 005500 FD Trans-File. 005600 01 Trans-Rec. 005700 88 End-Of-Trans Value High-Value. 005800 05 Type-Code Pic 9(01). 005900 88 Add-To-Stock Value 1. 006000 88 Remove-From-Stock Value 2. 006100 05 Oil-Num. 006200 10 Rel-Rec-Num Pic 9(03). 006300 10 Pic 9(01). 006400 05 Qty Pic 9(05). 006500 05 Pic X(70). 006600 006700 FD Report-File Global. 006800 01 Report-Rec Pic X(80). 006900 007000 FD Error-File. 007100 01 Error-Rec Pic X(80). 007200 007300 Working-Storage Section. 007400 007500 01 PrintPgm Pic 9(01) Global Value 0. 007600 88 First-Print-Line Value 0. 007700 88 Not-First-Print-Line Value 1. 007800 88 Last-Print-Line Value 2. 007900 008000 008100 01 Status-Codes Global. 008200 02 ODF-Status Pic X(02). 008300 88 Duplicate-Oil-Name Value '02'. 008400 02 OSF-Status Pic X(02). 008500 88 No-Error-Found Value '00'. 008600 88 Rec-Not-Found Value '23'. 008700 008800 01 WS-Rel-Rec-Num Pic 9(03) Global. 008900 01 Stock-Value Pic 9(05)V99 Value 0 Global. 009000 01 Total-Stock-Value Pic 9(05)V99 Value 0 Global. 009100 009200 01 Stock-Detail-Line Global. 009300 05 Sdl-Oil-Name Pic X(20). 009400 05 Sdl-Oil-Num Pic 9(04). 009500 05 Pic X(04) Value Space. 009600 05 Sdl-Unit-Size Pic 9(02). 009700 05 Pic X(02) Value Space. 009800 05 Sdl-Qty-In-Stock Pic ZZ.ZZ9. 009900 05 Pic X(02) Value Space. 010000 05 Sdl-Stock-Value Pic ZZZ.ZZ9,99. 010100 010200 Procedure Division. 010300 Perform Open-Files 010400 010500 Perform Until End-Of-Trans 010600 Read Trans-File 010700 At End 010800 Set End-Of-Trans to True 010900 Not AT End 011000 Perform Process-Transactions 011100 End-Read 011200 End-Perform 011300 011400 Move Space to Oil-Name-ODF 011500 Start Oil-Details-File 011600 Key is Greater Than Oil-Name-ODF 011700 Invalid Key 011800 Display 'Start Error FS = ' ODF-Status 011900 Move 99 to Return-Code 012000 GoBack 012100 End-Start 012200 012300 012400 Perform Until End-Of-ODF 012500 Read Oil-Details-File Next Record 012600 At End 012700 Set End-Of-ODF to True 012800 Not At End 012900 Call 'CreateDetailLinePgm' 013000 End-Read 013100 End-Perform 013200 013300 Set Last-Print-Line to True 013400 Call 'PrintLinesPgm' 013500 013600 Perform Close-Files 013700 GoBack 013800 . 013900 014000 Process-Transactions. 014100 Move Rel-Rec-Num to WS-Rel-Rec-Num 014200 Read Oil-Stock-File 014300 Invalid Key 014400 Write 014500 Error-Rec FROM Trans-Rec 014600 End-Write 014700 Not Invalid Key 014800 Perform Rewrite-OSF 014900 End-Read 015000 . 015100 Rewrite-OSF. 015200 Evaluate True 015300 When Add-To-Stock 015400 Add Qty to Qty-In-Stock-OSF 015500 When Remove-From-Stock 015600 Subtract Qty from Qty-In-Stock-OSF 015700 When Other 015800 Display 'Type code not 1 or 2 Rec = ' Trans-Rec 015900 End-Evaluate 016000 016100 Rewrite OSF-Rec 016200 Invalid Key 016300 Display 'Problem on REWRITE FS= ' OSF-Status 016400 End-Rewrite 016500 . 016600 Read-Oil-Details-File. 016700 Read Oil-Details-File Next Record 016800 At End 016900 Set End-Of-ODF to True 017000 End-Read 017100 . 017200 017300 Open-Files. 017400 Open I-O Oil-Details-File 017500 Open I-O Oil-Stock-File 017600 If Not No-Error-Found 017700 Display 'Fel vid open av OSF ' 017800 Display 'Status: ' OSF-Status 017900 Move 99 to return-code 018000 Goback 018100 End-If 018200 Open OUTPUT Error-File 018300 Open INPUT Trans-File 018400 Open Output Report-File 018500 . 018600 Close-Files. 018700 Close Oil-Details-File 018800 Close Oil-Stock-File 018900 Close Error-File 019000 Close Trans-File 019100 Close Report-File 019200 . 019300*---------------------------------------------- 019400 Identification Division. 019500 Program-Id. CreateDetailLinePgm. 019600*---------------------------------------------- 019700 Data Division. 019800 Working-Storage Section. 019900 01 Old-Oil-Name Pic X(20). 020000 020100 Procedure Division. 020200 If Old-Oil-Name = Oil-Name-ODF 020300 Move '+' to Sdl-Oil-Name 020400 Else 020500 Move Oil-Name-ODF to Sdl-Oil-Name 020600 End-If 020700 Move Oil-Name-ODF to Old-Oil-Name 020800 Move Oil-Num-ODF to Sdl-Oil-Num 020900 Move Unit-Size-ODF to Sdl-Unit-Size 021000 021100 Move Oil-Num-ODF(1:3) to WS-Rel-Rec-Num 021200 Read Oil-Stock-File 021300 Invalid Key 021400 Display '*** Read OSF error FS:' OSF-Status 021500 Display '*** RRN: ' W-Rel-Rec-Num 021600 Move 98 to return-code 021700 Goback 021800 Not Invalid Key 021900 Compute Stock-Value = 022000 Unit-Cost-ODF * Qty-In-Stock-OSF 022100 Move Stock-Value to Sdl-Stock-Value 022200 Move Qty-In-Stock-OSF to Sdl-Qty-In-Stock 022300 End-Read 022400 022500 Call 'PrintLinesPgm' 022600 . 022700 End Program CreateDetailLinePgm. 022800 022900*---------------------------------------------- 023000 Identification Division. 023100 Program-Id. PrintLinesPgm is COMMON Program. 023200*---------------------------------------------- 023300 Data Division. 023400 Working-Storage Section. 023500 023600 01 Space-Line Pic X(50) Value Space. 023700 023800 01 Header-Line. 023900 05 Pic X(18) Value 'Oil Stock Report'. 024000 024100 01 Stock-Detail-Header. 024200 05 Pic X(20) Value 'Oil Name'. 024300 05 Pic X(08) Value 'Oil Nr'. 024400 05 Pic X(07) Value 'Size'. 024500 05 Pic X(04) Value 'Qty'. 024600 05 Pic X(15) Value 'Stock Value'. 024700 024800 01 Trailer-Detail-Summary-Line. 024900 05 Pic X(21) Value Space. 025000 05 Pic X(18) Value 'Total Oil Value'. 025100 05 Tds-Stock-Value Pic ZZZZ.ZZZ,99. 025200 025300 01 Trailer-Summary-Report-Line. 025400 05 Pic X(14) Value Space. 025500 05 Pic X(25) Value 'Total Stock Value'. 025600 05 Tsr-Stock-Value Pic ZZZZ.ZZZ,99. 025700 025800 01 Old-Oil-Name Pic X(20). 025900 01 Report-Total-Stock-Value Pic 9(08)V99. 026000 026100 Procedure Division. 026200 Evaluate True 026300 When First-Print-Line 026400 Perform Print-Header-Lines 026500 Perform Print-Detail-Line 026600 When Last-Print-Line 026700 Perform Print-Trailer-Summary-Line 026800 When Old-Oil-Name NOT = Oil-Name-ODF 026900 Perform Print-Detail-Summary-Line 027000 Perform Print-Detail-Line 027100 When Other 027200 Perform Print-Detail-Line 027300 End-Evaluate 027400 027500 Exit Program 027600 . 027700 Print-Detail-Line. 027800 Add Stock-Value to Total-Stock-Value 027900 Write Report-Rec from Stock-Detail-Line 028000 Add Total-Stock-Value to Report-Total-Stock-Value 028100 Move Oil-Name-ODF to Old-Oil-Name 028200 . 028300 Print-Header-Lines. 028400 Write Report-Rec from Header-Line 028500 Write Report-Rec from Space-Line 028600 Write Report-Rec from Stock-Detail-Header 028700 Write Report-Rec from Space-Line 028800 Set Not-First-Print-Line to True 028900 . 029000 Print-Trailer-Summary-Line. 029100 Write Report-Rec from Space-Line 029200 Move Report-Total-Stock-Value to Tsr-Stock-Value 029300 Write Report-Rec from Trailer-Summary-Report-Line 029400 . 029500 Print-Detail-Summary-Line. 029600 Display Space 029700 Move Total-Stock-Value to Tds-Stock-Value 029800 Move 0 to Total-Stock-Value 029900 030000 Write Report-Rec from Space-Line 030100 Write Report-Rec from Trailer-Detail-Summary-Line 030200 Write Report-Rec from Space-Line 030300 Write Report-Rec from Space-Line 030400 . 030500*---------------------------------------------- 030600 End Program PrintLinesPgm. 030700*---------------------------------------------- 030800 End Program AROMA3B. 030900*----------------------------------------------