1 / 7

Introduction to Tables/Arrays

Tables/Arrays. Introduction to Tables/Arrays. Please use the speaker notes for additional information. Table set-up.

tea
Télécharger la présentation

Introduction to Tables/Arrays

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Table set-up 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. 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. DEPT-NAME(4) DEPT-NAME(3) DEPT-NAME(2) DEPT-NAME(1) MENS^^WOMENSGIRLS^BOYS^^ 000000000111111111122222 123456789012345678901234 Character or position within table - total of 24 characters In this example, we are using actual numbers as the subscript to tell which DEPT-NAME.

  3. Table use: 1 MENS 2 WOMENS 3 GIRLS 4 BOYS Input: 05 DEPT-NO PIC 9. 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. 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. 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. 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.

  4. Move 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. DEPT-NO=2 points here. Input: 05 DEPT-NO PIC 9. Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Procedure Division MOVE: 2 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. Output records: 11111 Mary Smith WOMENS $40,000.00

  5. Move 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. DEPT-NO=3 points here. Input: 05 DEPT-NO PIC 9. Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Procedure Division MOVE: 3 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. Output records: 11111 Mary Smith WOMENS $40,000.00 12121 Jennifer Ames GIRLS $40,000.00

  6. Move 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. DEPT-NO=4 points here. Input: 05 DEPT-NO PIC 9. Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Procedure Division MOVE: 4 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. Output records: 11111 Mary Smith WOMENS $40,000.00 12121 Jennifer Ames GIRLS $40,000.00 12345 Stephen Daniels BOYS $40,000.00

  7. Move 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. DEPT-NO=1 points here. Input: 05 DEPT-NO PIC 9. Input records: 11111Mary Smith 24000000 12121Jennifer Ames 34000000 12345Stephen Daniels 44000000 13456Carl Hersey 14000000 Procedure Division MOVE: 1 MOVE DEPT-NAME (DEPT-NO) TO DEPT-NAME-PR. 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

More Related