Download presentation
Presentation is loading. Please wait.
Published byJocelin Leonard Modified over 9 years ago
1
1 Chapter 13 - Mutlilevel Tables System Concepts –User View of tables one dimension view two dimension view three dimension view
2
2 Figure 13.1 Multilevel Tables Responsibility 1 2 3 4 5 6 7 8 9 10 26,000 27,000 28,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 Responsibility level = 4 (a) One-Level Table
3
3 Figure 13.1 Multilevel Tables Responsibility level = 1 Experience level = 4 Responsibility 1 2 3 4 5 6 7 8 9 10 26,000 27,000 28,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 27,000 28,000 29,000 32,000 34,000 36,000 39,000 42,000 45,000 50,000 28,000 29,000 30,000 34,000 36,000 38,000 42,000 45,000 48,000 54,000 29,000 30,000 31,000 36,000 38,000 40,000 45,000 48,000 51,000 58,000 30,000 31,000 32,000 38,000 40,000 42,000 48,000 51,000 54,000 62,000 12345 Experience Responsibility level = 4 Experience level = 1 (b) Two-Level Table
4
4 Responsibility 1 2 3 4 5 6 7 8 9 10 28,000 29,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 29,000 30,000 31,000 34,000 36,000 39,000 42,000 45,000 50,000 30,000 31,000 32,000 36,000 38,000 42,000 45,000 48,000 54,000 31,000 32,000 33,000 38,000 40,000 45,000 48,000 51,000 58,000 32,000 33,000 34,000 40,000 42,000 44,000 50000 53,000 56,000 64,000 12345 Experience Figure 13.1 Multilevel Tables (c) Three-Level Table Responsibility 1 2 3 4 5 6 7 8 9 10 26,000 27,000 28,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 27,000 28,000 29,000 32,000 34,000 36,000 39,000 42,000 45,000 50,000 28,000 29,000 30,000 34,000 36,000 38,000 42,000 45,000 48,000 54,000 29,000 30,000 31,000 36,000 38,000 40,000 45,000 48,000 51,000 58,000 30,000 31,000 32,000 38,000 40,000 42,000 48,000 51,000 54,000 62,000 12345 Experience Region 1 Region 2 Region = 1 Responsibility level = 1 Experience level = 4 Region = 2 Responsibility level = 4 Experience level = 1 Region = 1 Responsibility level = 4 Experience level = 1
5
5 COBOL Implementation –Review of OCURS & REDEFINES clauses –Review of PERFORM VARYING statement –Representation of data storage and memory allocation
6
6 Figure 13.2 One-Level Table Responsibility 1 2 3 4 5 6 7 8 9 10 26,000 27,000 28,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 Responsibility level = 4 (a) User’s View 01 SALARY-VALUES. 05 FILLERPIC X(5)VALUE ‘26000’. 05 FILLERPIC X(5)VALUE ‘27000’. 05 FILLERPIC X(5)VALUE ‘28000’. 05 FILLERPIC X(5)VALUE ‘30000’. 05 FILLERPIC X(5)VALUE ‘32000’. 05 FILLERPIC X(5)VALUE ‘34000’. 05 FILLERPIC X(5)VALUE ‘36000’. 05 FILLERPIC X(5)VALUE ‘39000’. 05 FILLERPIC X(5)VALUE ‘42000’. 05 FILLERPIC X(5)VALUE ‘46000’. 01 SALARY-TABLE REDEFINES SALARY-VALUES. 05 SALARY OCCURS 10 TIMESPIC 9(5). (b) Initialization via the REDEFINES and VALUES Clauses SALARY-TABLE SALARY (1) 26000 SALARY (2) 27000 SALARY (3) 28000 SALARY (4) 30000 SALARY (5) 32000 SALARY (6) 34000 SALARY (10) 46000... (c) Storage Schematic
7
7 Figure 13.3 Two-Level Table Responsibility level = 1 Experience level = 4 Responsibility 1 2 3 4 5 6 7 8 9 10 26,000 27,000 28,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 27,000 28,000 29,000 32,000 34,000 36,000 39,000 42,000 45,000 50,000 28,000 29,000 30,000 34,000 36,000 38,000 42,000 45,000 48,000 54,000 29,000 30,000 31,000 36,000 38,000 40,000 45,000 48,000 51,000 58,000 30,000 31,000 32,000 38,000 40,000 42,000 48,000 51,000 54,000 62,000 12345Experience Responsibility level = 4 Experience level = 1 (a) User’s View
8
8 SALARY-TABLE EXP (1) 26000 EXP (2) 27000 EXP (3) 28000 EXP (4) 30000 EXP (5) 32000 SALARY (1) 46000 SALARY (2) 50000... RESPONSIBILITY (1)RESPONSIBILITY (10)... SALARY-VALUES (c) Storage Schematic Figure 13.3 Two-Level Table 01 SALARY-VALUES. 05 FILLERPIC X(5)VALUE ‘2600027000280002900030000’. 05 FILLERPIC X(5)VALUE ‘2700028000290003000031000’. 05 FILLERPIC X(5)VALUE ‘2800029000300003100032000’. 05 FILLERPIC X(5)VALUE ‘3000032000340003600038000’. 05 FILLERPIC X(5)VALUE ‘3200034000360003800040000’. 05 FILLERPIC X(5)VALUE ‘3400036000380004000042000’. 05 FILLERPIC X(5)VALUE ‘3600039000420004500048000’. 05 FILLERPIC X(5)VALUE ‘3900042000450004800051000’. 05 FILLERPIC X(5)VALUE ‘4200045000480005100054000’. 05 FILLERPIC X(5)VALUE ‘4600050000540005800062000’. 01 SALARY-TABLE REDEFINES SALARY-VALUES. 05 RESPONSIBILITY OCCURS 10 TIMES. 10 EXPERIENCE OCCURS 5 TIMES. 15 SALARYPIC 9(5). (b) Initialization via the REDEFINES and VALUES Clauses
9
9 Two level tables –Syntax Additional OCCURS clause Representation of data storage and memory allocation –Errors in compilation Incorrect number of subscripts Wrong Sequence Invalid subscript Examples –SALARY (6, 5), SALARY (5, 6) –SALARY-TABLE, RESPONSIBILITY (1) –EXPERIENCE (6, 5) same as salary(6,5) because salary is the only item under experience.
10
10 Figure 13.4 PERFORM VARYING with Two Subscripts PERFORM INITIALIZE-SALARIES VARYING RESPONSIBILITY-SUB FROM 1 BY 1 UNTIL RESPONSIBILITY-SUB > 10 AFTER EXPERIENCE-SUB FROM 1 BY 1 UNTIL EXPERIENCE-SUB > 5.... INITIALIZE-SALARIES. MOVE ZERO TO SALARY (RESPONSIBILITY-SUB, EXPERIENCE-SUB). PERFORM VARYING RESPONSIBILITY-SUB FROM 1 BY 1 UNTIL RESPONSIBILITY-SUB > 10 AFTER EXPERIENCE-SUB FROM 1 BY 1 UNTIL EXPERIENCE-SUB > 5 MOVE ZERO TO SALARY (RESPONSIBILITY-SUB, EXPERIENCE-SUB) END-PERFORM (a) Performing a Paragraph (b) In-Line Perform
11
11 Figure 13.4 continued (c) Variation of Subscripts 1 1 1 2 1 3 1 4 1 5 2 1 2 2 2 3 2 4 2 5 10 1 10 2 10 3 10 4 10 5... Responsibility Subscript Experience Subscript RESPONSIBILITY-SUB is set to 1 while EXPERIENCE-SUB varies from 1 to 5 RESPONSIBILITY-SUB is set to 2 while EXPERIENCE-SUB varies from 1 to 5 RESPONSIBILITY-SUB reaches 10 and EXPERIENCE-SUB varies from 1 to 5
12
12 Write out the 12 pair of values that will be assumed by SUB-1 and SUB-2 as a result of the statement: PERFORM 10-PROCESS-TABLE VARYING SUB-1 FROM 1 BY 1 UNTIL SUB-1 > 4 AFTER SUB-2 FROM 1 BY 1 UNTIL SUB-2 > 3
13
13 Given: 01 CORPORATE-DATA. 05 COMPANY OCCURS 10 TIMES 10 DIVISION-NAME PIC X (15). 10 YEARLY-FINANCIAL-DATA OCCURS 4 TIMES. 15 REVENUE PIC 9(7). 15 NET-INCOME PIC 9(7).
14
14 a. Indicate the storage schematic b. State whether the following are valid references. If not is error during compile or exe i.CORPORATE-DATA ii.COMPANY iii.COMPANY (8) iv.DIVISION-NAME (8) v.DIVISION-NAME (12) vi.YEARLY-FINANCIAL-DATA (4) vii.REVENUE (10,4) viii.NET-INCOME (10,4) ix.REVENUE (4,10)
15
15 Three Level Tables –Addition of third OCCURS clause –Subscripting order and requirements In order of occurs clauses –Representation of data storage and memory allocation –PERFORM VARYING statement in three dimension tables
16
16 (a) User’s View Responsibility 1 2 3 4 5 6 7 8 9 10 28,000 29,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 29,000 30,000 31,000 34,000 36,000 39,000 42,000 45,000 50,000 30,000 31,000 32,000 36,000 38,000 42,000 45,000 48,000 54,000 31,000 32,000 33,000 38,000 40,000 45,000 48,000 51,000 58,000 32,000 33,000 34,000 40,000 42,000 44,000 50000 53,000 56,000 64,000 12345Experience Responsibility 1 2 3 4 5 6 7 8 9 10 26,000 27,000 28,000 30,000 32,000 34,000 36,000 39,000 42,000 46,000 27,000 28,000 29,000 32,000 34,000 36,000 39,000 42,000 45,000 50,000 28,000 29,000 30,000 34,000 36,000 38,000 42,000 45,000 48,000 54,000 29,000 30,000 31,000 36,000 38,000 40,000 45,000 48,000 51,000 58,000 30,000 31,000 32,000 38,000 40,000 42,000 48,000 51,000 54,000 62,000 12345Experience Region 1 Region 2 Region = 1 Responsibility level = 1 Experience level = 4 Region = 2 Responsibility level = 4 Experience level = 1 Region = 1 Responsibility level = 4 Experience level = 1 Figure 13.10 Three-Level Tables
17
17 Figure 13.10 Three-Level Tables 01 SALARY-VALUES. 03 REGION-ONE. 05 FILLERPIC X(5)VALUE ‘2600027000280002900030000’. 05 FILLERPIC X(5)VALUE ‘2700028000290003000031000’. 05 FILLERPIC X(5)VALUE ‘2800029000300003100032000’. 05 FILLERPIC X(5)VALUE ‘3000032000340003600038000’. 05 FILLERPIC X(5)VALUE ‘3200034000360003800040000’. 05 FILLERPIC X(5)VALUE ‘3400036000380004000042000’. 05 FILLERPIC X(5)VALUE ‘3600039000420004500048000’. 05 FILLERPIC X(5)VALUE ‘3900042000450004800051000’. 05 FILLERPIC X(5)VALUE ‘4200045000480005100054000’. 05 FILLERPIC X(5)VALUE ‘4600050000540005800062000’. 03 REGION-TWO. 05 FILLERPIC X(5)VALUE ‘2800029000300003100032000’. 05 FILLERPIC X(5)VALUE ‘2900030000310003200033000’. 05 FILLERPIC X(5)VALUE ‘3000031000320003300034000’. 05 FILLERPIC X(5)VALUE ‘3200034000360003800040000’. 05 FILLERPIC X(5)VALUE ‘3400036000380004000042000’. 05 FILLERPIC X(5)VALUE ‘3600038000400004200044000’. 05 FILLERPIC X(5)VALUE ‘3800041000440004700050000’. 05 FILLERPIC X(5)VALUE ‘4100044000470005000053000’. 05 FILLERPIC X(5)VALUE ‘4400047000500005300056000’. 05 FILLERPIC X(5)VALUE ‘4800052000560006000064000’. 01 SALARY-TABLE REDEFINES SALARY-VALUES. 05 REGION OCCURS 2 TIMES. 10 RESPONSIBILITY OCCURS 10 TIMES. 15 EXPERIENCE OCCURS 5 TIMES. 20 SALARYPIC 9(5). (b) Initialization via the REDEFINES and VALUES Clauses
18
18 SALARY-TABLE SALARY-VALUES (c) Storage Schematic Figure 13.10 Three-Level Tables EXP (1) 26000 EXP (2) 27000 EXP (3) 28000 EXP (4) 30000 EXP (5) 32000 RESPONSIBILITY (1) EXP (1) 26000 EXP (2) 27000 EXP (3) 28000 EXP (4) 30000 EXP (5) 32000 RESPONSIBILITY (10)... REGION (1) EXP (1) 26000 EXP (2) 27000 EXP (3) 28000 EXP (4) 30000 EXP (5) 32000 RESPONSIBILITY (1) EXP (1) 26000 EXP (2) 27000 EXP (3) 28000 EXP (4) 30000 EXP (5) 32000 RESPONSIBILITY (10)... REGION (2)
19
19 How to reference SALARY (1, 2, 3) region 1, responsibility 2, experience 3 SALARY (2, 12, 7) error- no responsibility 12 or experience 7 SALARY-TABLE entire table of data, no use subscripts REGION (1) refers to the 10 responsibility levels, each containing 5 experience levels of the 1 st region
20
20 RESPONSIBILITY (1, 2) refers to the 5 experience levels for responsibility level 2, region 1. Referenced with 2 subscripts EXPERIENCE (1, 2, 3) equivalent to SALARY (1, 2, 3) because SALARY is the only elementary item under the group EXPERIENCE.
21
21 Figure 13.11 PERFORM VARYING with Three Subscripts PERFORM INITIALIZE-SALARIES VARYING REGION-SUB FROM 1 BY 1 UNTIL REGION-SUB > 2 AFTER RESPONSIBILITY-SUB FROM 1 BY 1 UNTIL RESPONSIBILITY-SUB > 10 AFTER EXPERIENCE-SUB FROM 1 BY 1 UNTIL EXPERIENCE-SUB > 5.... INITIALIZE-SALARIES. MOVE ZERO TO SALARY (REGION-SUB, RESPONSIBILITY-SUB, EXPERIENCE-SUB). (a) Performing a Paragraph (b) In-Line Perform PERFORM VARYING REGION-SUB FROM 1 BY 1 UNTIL REGION-SUB > 2 AFTER RESPONSIBILITY-SUB FROM 1 BY 1 UNTIL RESPONSIBILITY-SUB > 10 AFTER EXPERIENCE-SUB FROM 1 BY 1 UNTIL EXPERIENCE-SUB > 5 MOVE ZERO TO SALARY (REGION-SUB, RESPONSIBILITY-SUB, EXPERIENCE-SUB) END-PERFORM.
22
22 Figure 13.11 ( c) Variation of Subscripts 111112113114115111112113114115... Responsibility Subscript Experience Subscript REGION-SUB and RESPONSIBILITY-SUB are both set to 1 while EXPERIENCE-SUB varies from 1 to 5 Region Subscript 121122123124125121122123124125 REGION-SUB remains at 1 while RESPONSIBILITY-SUB is incremented to 2 and EXPERIENCE-SUB is again varied from 1 to 5 1101 1102 1103 1104 1105 At the 50th iteration, REGION-SUB is still set to 1, but RESPONSIBILITY-SUB has reached 10. 211212213214215211212213214215 REGION-SUB is incremented to 2, RESPONSIBILITY-SUB is reset to 1 while EXPERIENCE-SUB varies from 1 to 5 2101 2102 2103 2104 2105... At the 100th iteration, REGION-SUB reaches 2, RESPONSIBILITY-SUB has reaches 10, EXPERIENCE-SUB reaches 5.
23
23 Indicate the 24 sets of different subscripts of the following: PERFORM VARYING SUB-1 FROM 1 BY 1 UNTIL SUB-1 > 3 AFTER SUB-2 FROM 1 BY 1 UNTIL SUB-2 > 3 AFTER SUB-3 FROM 1 BY 1 UNTIL SUB-3 > 4
24
24 Write the record structure that will hold data for 2 sections of COBOL, each sections having 40 students, each student will submit 6 projects and take 3 exams.
25
25 01 ENROLLMENT-DATA. 05 COLLEGE OCCURS 3 TIMES 10 MAJOR CODE OCCURS 50 TIMES 15 YEAR OCCURS 4 TIMES. 20 NUM-OF-STUDENT PIC 9(4). A.Write the schematic
26
26 Are the following legal from the previous solution 1.ENROLLMENT-DATA 2.COLLEGE (1) 3.MAJOR (1) 4.YEAR (1) 5.NUMBER-OF-STUDENT (1) 6.NUMBER-OF-STUDENT (1, 2, 3) 7.NUMBER-OF-STUDENT (4, 5, 6)
27
27 Write the PERFORM VARYING statements to determine 1.The total number of students in the university 2.The total number of seniors in the first college 3.The total number of students in the first major of the first college. 4.The total number of freshmen (year 1) in the first college. 5.The total number of freshmen in the university.
28
28 Given the following table definition: 01CORPORATE-SALES-TABLE 05BRANCH-OFFICE OCCURS 6 TIMES. 10 BRANCH-NAMEPIC X(10). 10 MONTHS OCCURS 12 TIMES. 15 SALES-AMOUNTPIC 9(6)
29
29 Indicate the appropriate storage schematic
30
30 Write a PERFORM VARYING statement to determine the annual sales for the third branch office.
31
31 Write a PERFORM VARYING statement to determine the corporate sales for May.
32
32 Write a PERFORM VARYING statement to determine the corporate sales for the entire year.
33
33 What are the differences between 1 & 2 & 3 level tables?
34
34 Code the DATA division entries necessary to define a table named A- TABLE with 5 rows and 20 columns. Each element of A-TABLE should have a PIC of S9(5)V99: Add room for 3 tables:
35
35 From the original table, code the statement that adds the 1 st element of the 1 st row and the 3 rd element of the 2 nd row and puts the result in the last element of the 4 th row:
36
36 Write the code to determine how many elements are equal in the first 2 rows of A-TABLE.
37
37 Write the code to find the element in each row that is equal to A-ITEM. If found perform PARA-A else perform ERROR- RTN.
38
38 Table lookups –Two level lookup –Program specifications –Range-step tables –Program Listing
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.