Logical Expressions - Valid Reference?

f IS [NOT] BOUND determines if the reference variable f contains a valid reference. f must be a data or an object reference variable. If you specify a function method call instead of f, the method must have a return value that is typed accordingly.

The logical expression is true for a data reference if the reference can be dereferenced. The logical expression is true for an object reference if the reference points to an objct.

The logical expression is always false if f contains the zero reference. However, there might be data references where f indeed does not contain the zero reference but where the reference contained is invalid because the object no longer exists. For example, a global data reference may point to a local data object of a procedure which is deleted after the procedure is exited. In this case, the reference is no longer bound to the destination, and the logical expression is also false.

Example

data DREF type ref to DATA.

start-of-selection.

  perform: TEST,
           CREATE,
           TEST.

form CREATE.
  data INT type I.
  get reference of INT into DREF.
  perform TEST.
endform.

form TEST.
  if DREF is bound.
    write / 'Bound'.
  else.
    write / 'Unbound'.
  endif.
endform.

The logical expression is only true in the subroutine CREATE.

Exceptions

Non-Catchable Exceptions