LOOKUPV

Searches a key-sequenced data set (KSDS) VSAM file for a record that contains a specified string in the key. Enrichment returns up to a specified number of bytes of the record that contains the matching information. The LOOKUPV function is valid only on mainframe systems.

Use the LOOKUP function to look up information in flat files or tables. Enrichment allows unlimited unique files for LOOKUP and LOOKUPV processing in a single application.

You can use the WRITEV function to update the same file used in LOOKUPV. If you use WRITEV with LOOKUPV, access must be set to W. You can use the SUBSTR function to parse the return from LOOKUPV to obtain specific variables.

Syntax

LOOKUPV(filename,key,[size,search,access])

Arguments

Argument Description Default
filename The specification of the KSDS VSAM file that contains the records to search. filename may be up to 255 characters in length. You can use the same VSAM file in multiple LOOKUPV calls. Specify filename in exactly the same manner for all calls to the same file. Enrichment only opens the VSAM file once. None
key The key used to identify a matching record in the VSAM file based on search. Enrichment performs a generic search if the length of key is less than that specified for the VSAM file key. A generic search is one in which the search key is a leading portion of the field. None
[size] The record size or maximum number of characters to return from the VSAM file. 80
[search] One of the following to indicate the type of search to perform: E
B Positions to the previous record that contains key.
E Positions to the first record that contains key.
G Positions to the first record with a key greater than or equal to key.
[access] One of the following to indicate the type of access: W
R Read-only access.
W Read/write access. Some WRITEV features require write access to the LOOKUPV positioning.

Results

Result Description
Return The record from filename that contained key.
%%RC One of the following:
0 No error.
1 No matching record was found. The return is ' '.
2 Enrichment could not read the matching record from the VSAM file. The return will contain the mainframe system error message from the LOOKUPV operation.
3 Missing or empty LOOKUPV file.
4 Record length size invalid.
%%RM A null string ('').
%%RV The C Error Number from the LOOKUPV operation if the read failed. Otherwise, 0.

Example

A VSAM file contains the following records:

089001021Y
073012033N
083210055N
010213121Y
.
.
.

in which columns 1 through 6 indicate a customer number (which is defined as key), columns 7 through 9 indicate a branch office ID, and column 10 indicates a special customer status.

Within the rule file for the application, you can use LOOKUPV to find records that contain the customer number. Then, Enrichment can use the return from LOOKUPV to do the following:

  • Add a personalized page for special customers.
  • Outsort the documents based on branch office ID.

To achieve the desired result, rule file syntax might resemble the following:

 %%answer=LOOKUPV('DD:VSAM',%%custnumber,10,E,R) 
IF %%RC<>0 THEN 
   %%branch=1 
   %%special='N' 
ELSE 
   %%branch=SUBSTR(%%answer,7,3) 
   %%special=SUBSTR(%%answer,10,1) 
ENDIF 
IF(%%special='Y') THEN 
   <INPUT>SPECIAL 
ENDIF 
IF(%%branch>50) 
   <OUTPUT>WEST 
ELSE 
   <OUTPUT>EAST 
ENDIF