Accessing Fields in Joined Data Structures With LOOKUP in VSAM

Use the MODIFY LOOKUP function to retrieve data values from cross-referenced data structures. To use LOOKUP with VSAM data sources, issue a JOIN command to link them and then issue a LOOKUP on the key field or alternate index.

LOOKUP is required because, unlike TABLE requests, MODIFY requests cannot freely read cross-referenced files. The LOOKUP function enables you to issue requests containing retrieved data values in computations and messages.

LOOKUP is valid in both COMPUTE and VALIDATE statements. Requests can use the data retrieved in the computations or validations within MODIFY procedures. Use LOOKUP to locate values in any data sources that can be linked with the JOIN command.

You cannot modify data in the cross-referenced file. To modify files other than the host file in a request, use the COMBINE command described in Modifying Multiple Data Sources: The COMBINE Facility.

Syntax: Using the LOOKUP Function in VSAM

rcode = LOOKUP(field);

where:

rcode
Is the variable (you specify) to receive a return code. The return code value is 1 if LOOKUP can locate a cross-referenced segment instance or 0 if it cannot.

field
Is the name of the field to be retrieved in the cross-referenced file. LOOKUP retrieves a single field at a time. Each requires a separate LOOKUP.

Syntax note: no space is permitted between LOOKUP and the left parentheses. LOOKUP can exist by itself or as part of a larger expression. If it is used by itself, it must end in a semicolon.

The extended syntax of the LOOKUP function, described in your FOCUS documentation, does not apply to the VSAM Interface. You can only retrieve exact match values.

When using LOOKUP, the MODIFY request reads a transaction for the host field value. LOOKUP then searches the cross-referenced segment for an instance with this value in the cross-referenced field:


Information Builders