OBJECTS_OBJREF_NOT_ASSIGNED¶
A method or attribute was accessed on an object reference that is still initial (null).
The reference variable was declared but never pointed at an actual object instance before you called a method or read an attribute on it.
Symptom¶
ST22 shows:
Runtime Errors OBJECTS_OBJREF_NOT_ASSIGNED
Exception CX_SY_REF_IS_INITIAL
Short text Access via 'NULL' object reference not possible.
The dump line is the -> dereference, not where the variable was declared.
Cause¶
A variable declared with TYPE REF TO starts as INITIAL — it holds no object. Any -> access on an initial reference dumps immediately.
Common triggers:
- A factory method returned nothing (e.g.
cl_salv_table=>factory( )raised an exception you swallowed) and you used the output anyway. READ TABLE ... INTO DATA(lo_ref)didn't find a row —lo_refis still initial after the read.ASSIGN ... TO <fs>on a non-existent component left the field-symbol unassigned, then you dereferenced it.- A method parameter typed
TYPE REF TOwas left unfilled by an optional caller.
Reproduce¶
DATA lo TYPE REF TO cl_salv_table.
" lo is still initial — no CREATE OBJECT, no factory call
lo->display( ). " <-- OBJECTS_OBJREF_NOT_ASSIGNED dumps here
Field-symbol variant:
FIELD-SYMBOLS: <fs> TYPE REF TO cl_salv_table.
" <fs> never assigned
<fs>->display( ). " <-- dumps here
Fix¶
IS BOUND vs IS INITIAL
For object references IS BOUND is the correct check — it returns false for both initial references and references to objects that have been freed. IS INITIAL also works but does not detect freed objects. For field-symbols use IS ASSIGNED.
Prevention¶
- After every factory call (
cl_salv_table=>factory,io_context->get_..., etc.) checkIS BOUNDbefore proceeding. - After
READ TABLE ... INTO DATA(lo_ref), always checkSY-SUBRC = 0before usinglo_ref. - Declare method parameters
OPTIONALonly when the caller genuinely does not need to supply them, and guard against the initial case inside the method. - Enable extended program check (transaction
SLIN) — it flags most unguarded dereferences statically.
See also¶
CX_SY_REF_IS_INITIAL— exception class raised by this dump- Transaction ST22 — ABAP runtime error analysis