The NOOPT keyword indicates that no optimization is to be performed on
the standalone field, parameter or data structure for which this keyword is
specified. Specifying NOOPT ensures that the content of the data item is the
latest assigned value. This may be necessary for those fields whose values
are used in exception handling.
Note: The optimizer may keep some
values in registers and restore them only to storage at predefined points
during normal program execution. Exception handling may break this normal execution sequence, and consequently program variables contained
in registers may not be returned to their assigned storage locations. As a
result, when those variables are used in exception handling, they may not
contain the latest assigned value. The NOOPT keyword will ensure their currency.
If a data item which is to be passed by reference is defined with the NOOPT
keyword, then any prototype or procedure interface parameter definition must
also have the NOOPT keyword specified. This requirement does not apply to
parameters passed by value.
Tip: Any data item defined in an OPM RPG/400® program is implicitly defined with
NOOPT. So if you are creating a prototype for an OPM program, you should specify
NOOPT for all parameters defined within the prototype. This will avoid errors
for any users of the prototype.
All keywords allowed for standalone field definitions, parameters, or data
structure definitions are allowed with NOOPT.