Compaq AAQ2G1FTK Marine Radio User Manual


 
Handling Tables
4.3 Accessing Table Elements
Example 4–18 (Cont.) Sample Table
02 MARRIED-DEDUCTION-DATA.
03 FILLER PIC X(119) VALUE
"04800096000000017
- "09600173000081620
- "17300264000235617
- "26400346000390325
- "34600433000595328
- "43300500000838932
- "50000999991053336".
02 MARRIED-DEDUCTION-TABLE REDEFINES MARRIED-DEDUCTION-DATA.
03 MARRIED-TABLE OCCURS 7 TIMES
ASCENDING KEY IS M-MIN-RANGE M-MAX-RANGE
INDEXED BY IND-0, IND-3.
04 M-MIN-RANGE PIC 99999.
04 M-MAX-RANGE PIC 99999.
04 M-TAX PIC 99999.
04 M-PERCENT PIC V99.
Example 4–19 shows how to perform a serial search.
Example 4–19 A Serial Search
01 TAXABLE-INCOME PIC 9(6) VALUE 50000.
01 FED-TAX-DEDUCTION PIC 9(6).
PROCEDURE DIVISION.
BEGIN.
PERFORM SINGLE.
DISPLAY FED-TAX-DEDUCTION.
STOP RUN.
SINGLE.
IF TAXABLE-INCOME < 02500
GO TO END-FED-COMP.
SET IND-2 TO 1.
SEARCH SINGLES-TABLE AT END
GO TO TABLE-2-ERROR
WHEN TAXABLE-INCOME = S-MIN-RANGE(IND-2)
MOVE S-TAX(IND-2) TO FED-TAX-DEDUCTION
WHEN TAXABLE-INCOME < S-MAX-RANGE(IND-2)
COMPUTE FED-TAX-DEDUCTION =
S-TAX(IND-2) + (TAXABLE-INCOME - S-TAX(IND-2)) *
S-PERCENT(IND-2).
.
.
.
Example 4–20 shows how to use SEARCH while varying an index other than the
first index.
Example 4–21 shows how to use SEARCH while varying an index data item.
4–20 Handling Tables