Upload
piers-bradford
View
216
Download
0
Embed Size (px)
Citation preview
Introduction to Tables/Arrays
Please use the speaker notes for additional information.
Tables/ArraysTables/Arrays
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^^
000000000111111111122222123456789012345678901234
Table set-upTable 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
Input:
05 DEPT-NO PIC 9.
1 MENS2 WOMENS3 GIRLS4 BOYS
Table use: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.
Input records:
11111Mary Smith 2400000012121Jennifer Ames 3400000012345Stephen Daniels 4400000013456Carl Hersey 14000000
Output records:
11111 Mary Smith WOMENS $40,000.00
Procedure Division MOVE: 2MOVE 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.
MoveMove
DEPT-NO=2 points here.
Input records:
11111Mary Smith 2400000012121Jennifer Ames 3400000012345Stephen Daniels 4400000013456Carl Hersey 14000000
Output records:
11111 Mary Smith WOMENS $40,000.00 12121 Jennifer Ames GIRLS $40,000.00
Procedure Division MOVE: 3MOVE 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.
MoveMove
DEPT-NO=3 points here.
Input records:
11111Mary Smith 2400000012121Jennifer Ames 3400000012345Stephen Daniels 4400000013456Carl 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: 4MOVE 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.
MoveMove
DEPT-NO=4 points here.
Input records:
11111Mary Smith 2400000012121Jennifer Ames 3400000012345Stephen Daniels 4400000013456Carl 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: 1MOVE 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.
MoveMoveDEPT-NO=1 points here.