Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Tables/Arrays Please use the speaker notes for additional information. Tables/Arrays.

Similar presentations


Presentation on theme: "Introduction to Tables/Arrays Please use the speaker notes for additional information. Tables/Arrays."— Presentation transcript:

1 Introduction to Tables/Arrays Please use the speaker notes for additional information. Tables/Arrays

2 01 DEPT-TABLE. 05 FILLER PIC X(6) VALUE ”MENS ". 05 FILLER PIC X(6) VALUE ”WOMENS". 05 FILLER PIC X(6) VALUE ”GIRLS ". 05 FILLER PIC X(6) VALUE ”BOYS ". 01 RDF-DEPT-TABLE REDEFINES DEPT-TABLE 05 DEPT-NAME PIC X(6) OCCURS 4 TIMES. MENS^^WOMENSGIRLS^BOYS^^ 000000000111111111122222 123456789012345678901234 Table set-up DEPT-NAME(1) DEPT-NAME(2) DEPT-NAME(3) DEPT-NAME(4) The table is set up with four names for the four departments. Then the table is redefined to look at the table in a different way. The redefinition results in 4 fields each with the name DEPT-NAME and all 6 characters long. This is done with the OCCURS which essentially says there are 4 DEPT-NAMEs. Therefore, to use DEPT-NAME we have to modify it with a SUBSCRIPT or pointer to tell which DEPT-NAME we want. In the example below, there is DEPT-NAME(1), DEPT-NAME(2) etc. In this example, we are using actual numbers as the subscript to tell which DEPT-NAME. Character or position within table - total of 24 characters

3 Input: 05 DEPT-NO PIC 9. 1 MENS 2 WOMENS 3 GIRLS 4 BOYS Table use: 01 DEPT-TABLE. 05 FILLER PIC X(6) VALUE ”MENS ". 05 FILLER PIC X(6) VALUE ”WOMENS". 05 FILLER PIC X(6) VALUE ”GIRLS ". 05 FILLER PIC X(6) VALUE ”BOYS ". 01 RDF-DEPT-TABLE REDEFINES DEPT-TABLE 05 DEPT-NAME PIC X(6) OCCURS 4 TIMES. In the PROCEDURE DIVISION: B-200-LOOP. MOVE EMP-IDNO TO EMP-IDNO-PR. MOVE EMP-NAME TO EMP-NAME-PR. MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. MOVE SALARY TO SALARY-PR. The MENS dept will have a code of 1 in DEPT-NO, the WOMENS dept will have a code of 2 in DEPT-NO, 3 for the GIRLS and 4 for the BOYS. This line will move the DEPT-NAME subscripted by the DEPT-NO to DEPT-NAME-PR. Lets say the input record had 3 in DEPT-NO, than moving DEPT-NAME(DEPT-NO) will move GIRLS to DEPT-NAME-PR.

4 Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Output records: 11111 Mary Smith WOMENS $40,000.00 Procedure Division MOVE: 2 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. 01 DEPT-TABLE. 05 FILLER PIC X(6) VALUE ”MENS ". 05 FILLER PIC X(6) VALUE ”WOMENS". 05 FILLER PIC X(6) VALUE ”GIRLS ". 05 FILLER PIC X(6) VALUE ”BOYS ". 01 RDF-DEPT-TABLE REDEFINES DEPT-TABLE 05 DEPT-NAME PIC X(6) OCCURS 4 TIMES. Input: 05 DEPT-NO PIC 9. Move DEPT-NO=2 points here.

5 Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Output records: 11111 Mary Smith WOMENS $40,000.00 12121 Jennifer Ames GIRLS $40,000.00 Procedure Division MOVE: 3 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. 01 DEPT-TABLE. 05 FILLER PIC X(6) VALUE ”MENS ". 05 FILLER PIC X(6) VALUE ”WOMENS". 05 FILLER PIC X(6) VALUE ”GIRLS ". 05 FILLER PIC X(6) VALUE ”BOYS ". 01 RDF-DEPT-TABLE REDEFINES DEPT-TABLE 05 DEPT-NAME PIC X(6) OCCURS 4 TIMES. Input: 05 DEPT-NO PIC 9. Move DEPT-NO=3 points here.

6 Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Output records: 11111 Mary Smith WOMENS $40,000.00 12121 Jennifer Ames GIRLS $40,000.00 12345 Stephen Daniels BOYS $40,000.00 Procedure Division MOVE: 4 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. 01 DEPT-TABLE. 05 FILLER PIC X(6) VALUE ”MENS ". 05 FILLER PIC X(6) VALUE ”WOMENS". 05 FILLER PIC X(6) VALUE ”GIRLS ". 05 FILLER PIC X(6) VALUE ”BOYS ". 01 RDF-DEPT-TABLE REDEFINES DEPT-TABLE 05 DEPT-NAME PIC X(6) OCCURS 4 TIMES. Input: 05 DEPT-NO PIC 9. Move DEPT-NO=4 points here.

7 Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Output records: 11111 Mary Smith WOMENS $40,000.00 12121 Jennifer Ames GIRLS $40,000.00 12345 Stephen Daniels BOYS $40,000.00 13456 Carl Hersey MENS $40,000.00 Procedure Division MOVE: 1 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. 01 DEPT-TABLE. 05 FILLER PIC X(6) VALUE ”MENS ". 05 FILLER PIC X(6) VALUE ”WOMENS". 05 FILLER PIC X(6) VALUE ”GIRLS ". 05 FILLER PIC X(6) VALUE ”BOYS ". 01 RDF-DEPT-TABLE REDEFINES DEPT-TABLE 05 DEPT-NAME PIC X(6) OCCURS 4 TIMES. Input: 05 DEPT-NO PIC 9. Move DEPT-NO=1 points here.


Download ppt "Introduction to Tables/Arrays Please use the speaker notes for additional information. Tables/Arrays."

Similar presentations


Ads by Google