ONKEY Function

Purpose

Returns the key value that precipitated the signaling of the condition during an input/output operation to a file that is being accessed.

Syntax

ONKEY()

Description

The ONKEY function returns the key value that precipitated the signaling of the KEY condition during an input/output operation to a file that is being accessed by key.

The ONKEY function can be used in an ON-unit established for the ENDFILE, KEY, RECORD, and UNDEFINEDFILE conditions. It can also be used for an ERROR ON-unit that obtains control as a result of the default Open PL/I action for the KEY condition. (The default action is to signal the ERROR condition.)

The returned value is a varying length character string.

Examples

ON KEY(DFILE) BEGIN;
 PUTEDIT ('DFILE KEY',ONKEY(),'NOT FOUND')(SKIP,3 A); 
END;

Restrictions

If the ONKEY function is referenced outside an ON-unit or within an ON-unit executed as a consequence of a condition not related to a file being accessed by key, it will return the null string.