Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

ON statement

The ON statement establishes the action to be executed for any subsequent raising of an enabled condition in the scope of the established condition.

Read syntax diagramSkip visual syntax diagram       .-,---------.
       V           |
>>-ON----condition-+--+------+--+-SYSTEM;-+--------------------><
                      '-SNAP-'  '-ON-unit-'
 
condition
Is any one of those described in Conditions or defined with the CONDITION attribute.
SNAP
Specifies that when the enabled condition is raised, diagnostic information relating to the condition is printed. The action of the SNAP option precedes the action of the ON-unit.

If SNAP and SYSTEM are specified, the implicit action is followed immediately by SNAP information.

SYSTEM
Specifies that the implicit action is taken. The implicit action is not the same for every condition, although for most conditions a message is printed and the ERROR condition is raised. The implicit action for each condition is given in Conditions.
ON-unit
Specifies the action to be executed when the condition is raised and is enabled. The action is defined by the statement or statements in the ON-unit itself. When the ON statement is executed, the ON-unit is said to be established for the specified condition. The ON-unit is not executed at the time the ON statement is executed; it is executed only when the specified enabled condition is raised.

The ON-unit can be either a single unlabeled simple statement or an unlabeled begin-block. If it is a simple statement, it can be any statement except BEGIN, DECLARE, DEFAULT, DO, END, ENTRY, FORMAT, ITERATE, LEAVE, OTHERWISE, PROCEDURE, RETURN, SELECT, WHEN, or %statements. If the ON-unit is a begin-block, a RETURN statement can appear only within a procedure nested within the begin-block; a LEAVE statement can appear only within a do-group nested within the begin-block.

Except for ON-units consisting only of either a semicolon (;) or the RESIGNAL statement, an ON-unit is treated as a procedure (without parameters) that is internal to the block in which it appears. Any names referenced in an ON-unit are those known in the environment in which the ON statement for that ON-unit was executed, rather than the environment in which the condition was raised.

When execution of the ON-unit is complete, control generally returns to the block from which the ON-unit was entered. Just as with a procedure, control can be transferred out of an ON-unit by a GO TO statement. In this case, control is transferred to the point specified in the GO TO, and a normal return does not occur.

The specific point to which control returns from an ON-unit varies for different conditions. Normal return for each condition is described in Conditions.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)