Syntax
The LOOKUP command must specify the ON screen_name
clause. Available clauses are:
LOOKUP {lookup expression}
[NOT]ON screen_name[ /database.record | /tabfile.table]
BACKWARDS | FORWARDS n
ERROR nnn 'message'
IF ( expression )
IN expression
LOCK locktype
REPORT 'message'
RETURNING expression, ... TO variable, ...
USING caseid [ * ] | [ key, ... ]
VIA * | key, ...
lookup expression
If a lookup expression is specified, it is tested against the
expression specified on the IN clause. If a lookup expression
is not specified, do not specify an IN expression.
[NOT]ON
Specifies the screen which defines the record or table to be used
from the LOOKUP. ON or
NOTON is the only required clause. ON
checks that a record matching the search criteria exist.
NOTON returns an error message if a record matching the search
criteria exists.
screen_name
Specifies the name of another screen in this form. If the name of
the screen is different from the record or table name to which it refers,
specify the extended form of the name with the record name and the database name
if necessary.
BACKWARDS n|
FORWARDS n
Sets a record search direction. When the USING or
VIA specifies a partial key, the direction of search can be
set. The default direction is FORWARD. When a number is
specified, the nth record matching the search criteria is selected.
ERROR
Specifies the error messages (and video treatment) to replace the
default error messages. Error 59 is 'Lookup Failure' and error 60 is 'Lookup
Warning'.
IF
Specifies an expression that controls whether the
LOOKUP command is executed. If the expression is true, the
LOOKUP is performed. If it is false, the
LOOKUP is not performed.
IN
Specifies an expression using variables from the screen being looked
up which is tested against the source expression. If they are not equal, an
error message is issued. If the USING or
VIA clause specifies a complete key, that record is tested.
If the USING or VIA clause, specifies a
partial key, the defined set of records is searched for a match.
LOCK
Specifies the
lock the called screen uses when more than
concurrent operations (more than one user accessing the database) are envisaged.
There is no reason ever to have a lock type other than 'CR' for lookups.
REPORT
Specifies a string that is displayed when the lookup is successful.
To display values from the lookup record, use RETURNING to
copy the values to fields that are displayed on this screen.
RETURNING
Specifies the value(s) (variable names or expressions) from the
LOOKUP record that are transferred to the fields in the
TO list. The RETURNING and the
TO list are positionally matched. The first variable in the
RETURNING list is moved to the first variable in the
TO list, the second to the second and so on. Variables
referenced in the RETURNING list must be available to the
LOOKUP record; variables in the TO list must
be available to the current record.
USING
Specifies that the LOOKUP uses a different case.
Specify the case id value, optionally followed by other key field values.
Specify an asterisk (*) to indicate that the key fields of the current screen
are to be used. USING specifies a different case and thus
cannot be used for databases without case structures and cannot be used in
conjunction with the VIA clause.
VIA
Specifies the key fields for a LOOKUP within this
case, to another record on a caseless database or to a table screen. Specify
values for the key fields. Specify an asterisk (*) to indicate that the key
fields of the current screen are to be used. If the key is not unique for one
record, but defines a set of records, the first record in the set is used.
(This can be changed with the FORWARD and
BACKWARDS clauses).
Since the stand-alone lookup is not positioned on an input field, the test
cannot be "required" since control has to continue to the next field. Use the
lookup clause on the field command, to enforce the checking and re-entry of
fields. The stand alone lookup is normally used to retrieve data.
Example: This returns the location status to a temporary field
XSTATUS (which has been DECLARED on the
FORM command) and then displays the result.
LOOKUP ON LOCREC USING -1, LOCATION -
RETURNING STATUS to XSTATUS -
ERROR 59 'Invalid Location Code - Please Re-enter'
FIELD XSTATUS DISPLAY 'Location Status'