|
November 2004 Technical Tip – Lookup Tables with Easytrieve Anyone who has ever coded table load and lookup logic with another language will appreciate the ease with which one can do the same thing in Easytrieve. We'll keep this simple...assume the input file (ddname MYDATA) has two fields - name and state code - as shown here:
Our lookup table (ddname MYSTATES) has two fields - state code and state name - as shown here:
The lookup table is defined in the Easytrieve program as follows:
We define a working field to hold the (found?) state name:
The table lookup logic is included in the JOB portion of the Easytrieve program as follows:
Note the use of the IF statement which checks for a found/not found condition. This is required because if the argument is not found in the table, the target field (STATE-NAME here) is left unchanged. This could also be coded as:
The complete Easytrieve program with JCL is as follows:
The complete output is as follows:
Want to know more about Easytrieve? Give us a call! You can count on Caliber Data Training for top quality mainframe and/or internet programming education. Go to the articles index. Written by Bill Qualls. Copyright © 2004 by Caliber Data Training 800.938.1222 |