Using Files as Lookup tables in Easytrieve

Let us say, I have a lookup table file for Name of the Months. (DD name LOOKUP1 in our example program)

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
01 JANUARY
02 FEBRUARY
03 MARCH
04 APRIL
05 MAY
06 JUNE
07 JULY
08 AUGUST
09 SEPTEMBER
10 OCTOBER
11 NOVEMBER
12 DECEMBER

and I have another file (DD name ACTUAL) for which the month names have to be read from the above file.

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
05
12
33
03

Output File should have the month numbers from the ACTUAL file and should have fetched the month name from LOOKUP1 file and put in the output file.

Ie,

OUTFILE

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
05 MAY
12 DECEMBER
33 INVALID MON
03 MARCH

This Can be achieved by the following program which uses the LOOKUP1 file as a table.

The field names ARG and DESC should not be changed (because those are keywords).

And also the TABLE file should not have high level group variable for the full record.

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 LIST ON
 FILE LOOKUP1 TABLE
      ARG              1    2    A
      DESC             4   15    A
 FILE ACTUAL
      ACTUAL-REC        1    80   A
        MONTH-LIST      1     2   A
 FILE OUTFILE
      OUT-REC          1   80  A
      OUT-MONTH-NUM    1    2  A
      OUT-MONTH-NAME   4   15  A
 JOB INPUT NULL
 GET ACTUAL
     DO WHILE NOT EOF ACTUAL
        MOVE MONTH-LIST TO OUT-MONTH-NUM
        SEARCH LOOKUP1 WITH MONTH-LIST , GIVING OUT-MONTH-NAME
        IF NOT LOOKUP1
           MOVE 'INVALID MON' TO OUT-MONTH-NAME
        END-IF
        PUT OUTFILE
        GET ACTUAL
     END-DO
 STOP.
Advertisement

7 thoughts on “Using Files as Lookup tables in Easytrieve”

  1. Hi,If I have a file of few month numbers only say 01 05 10 and requirement is if month number from input file match any entry in month number file append Yes in the output record else append No in the output record.How this can be achieved.

  2. What is the limit on the Table Size to be searched. I am getting : A008 TOO MANY TABLE ENTRIES – DATETBL

  3. Hi Robert,
    Can you try specifying your table size in the FILE TABLE declaration?
    say, if you have 1500 records in your FILE, declare as FILE LOOKUP1 TABLE(1500)

    Thanks,
    Karthik.

    A008 TOO MANY TABLE ENTRIES – filename

    There are more table entries in the indicated external table file than
    specified on the related FILE statement. Recompile the program after
    increasing the value in the file’s TABLE parameter.

  4. A008 TOO MANY TABLE ENTRIES – filename

    This error is coming because,you can’t have more than 3,55,000 records in Lookup table

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.