120 likes | 211 Views
Hope you had a relaxing and productive break. We have six more weeks to go and a lot more tests to take. The START Statement Start Filename Key Relational Operator Invalid Key Statement Not Invalid Key Statement End-Start. Read Next Read Filename Next Record
E N D
Hope you had a relaxing and productive break We have six more weeks to go and a lot more tests to take
The START Statement • Start Filename Key Relational Operator • Invalid Key Statement • Not Invalid Key Statement • End-Start
Read Next • Read Filename Next Record • At End Statement • End-Read • File Status (Select Filename File Status is WS-STATUS) • Refer to pages 484 - 485)
ANNUAL-SALES-DATA SALES (1) SALES (2) SALES (12) . . . The Table Concept 01 ANNUAL-SALES-DATA. 05 JAN-SALES PIC 9(6). 05 FEB-SALES PIC 9(6). 05 MAR-SALES PIC 9(6). 05 APR-SALES PIC 9(6). 05 MAY-SALES PIC 9(6). 05 JUN-SALES PIC 9(6). 05 JUL-SALES PIC 9(6). 05 AUG-SALES PIC 9(6). 05 SEP-SALES PIC 9(6). 05 OCT-SALES PIC 9(6). 05 NOV-SALES PIC 9(6). 05 DEC-SALES PIC 9(6). (a) Brute Force 01 ANNUAL-SALES-DATA. 05 SALES OCCURS 12 TIMES PIC 9(6). (b) OCCURS Clause (c) Storage Schematic
The OCCURS clause is defined in the DATA DIVISION.A Subscript is used in the PROCEDURE DIVISION to access individual elements of the array. The subscript can be an integer or a data-name (example SUB).01 WORK-FIELDS. 05 SUB PIC 9(2).
SALARY-DATA (2) SALARY-DATA (1) SALARY-DATA (3) SALARY (2) SALARY (1) SALARY (3) SAL-DATE (2) SAL-DATE (1) SAL-DATE (3) Figure 11.4 OCCURS Clause at the Group Level 05 SALARY-DATA OCCURS 3 TIMES. 10 SALARY PIC 9(6)V99. 10 SAL-DATE PIC 9(4). (a) COBOL Statements (b) Storage Schematic
SALARY-DATA SALARY (1) SAL-DATE (1) SALARY (2) SAL-DATE (2) SALARY (3) SAL-DATE (3) OCCURS Clause at the Elementary Level 05 SALARY-DATA. 10 SALARY OCCURS 3 TIMES PIC 9(6)V99. 10 SAL-DATE OCCURS 3 TIMES PIC 9(4). (a) COBOL Statements (b) Storage Schematic
Processing a Table MOVE ZERO TO ANNUAL-TOTAL.PERFORM INCREMENT-ANNUAL-TOTAL VARYING SALES-SUB FROM 1 BY 1 UNTIL SALES-SUB > 12.. . .INCREMENT-ANNUAL-TOTAL. ADD SALES (SALES-SUB) TO ANNUAL-TOTAL. (a) Performing a Paragraph MOVE ZERO TO ANNUAL-TOTAL.PERFORM VARYING SALES-SUB FROM 1 BY 1 UNTIL SALES-SUB > 12 ADD SALES (SALES-SUB) TO ANNUAL-TOTALEND-PERFORM. (b) In-line Perform
Initializeidentifier-1 to FROM value Increment identifier-1 with BY value Perform procedure-1 or imperative- statement Evaluate condition=1 FALSE TRUE PERFORM VARYING (with TEST BEFORE)
Relative Subscripting CURRENT SALARY EFFECTIVE DATE PERCENT INCREASE $46,000 09/93 15.0% $40,000 09/92 11.1% $36,000 09/91 12.5% $32,000 09/90 (a) Salary History PERFORM VARYING SUB FROM 1 BY 1 UNTIL SUB > 3 OR SALARY (SUB + 1) = 0 COMPUTE PCT-SALARY-INC (SUB) = 100 * ((SALARY (SUB) - SALARY (SUB+1)) / SALARY (SUB + 1) END-COMPUTEEND-PERFORM (b) Computation of Percent Salary Increase