Get Example source ABAP code based on a different SAP table
VERSION 5 OUT • CL_ABAP_WEAK_REFERENCE ABAP_CLASS
Weak References An object in the system class CL_ABAP_WEAK_REFERENCE>> represents a weak reference> to an object in a class. Unlike regular object references >, a weak reference is ignored when the garbage collector> is executed. This means that a weak reference does not keep the referenced object from being deleted when the garbage collector is executed. A weak reference to an existing object is created by passing an object reference to the instance constructor of CL_ABAP_WEAK_REFERENCE>. The functional method> GET> can then be used to retrieve the reference afterwards. If the object was deleted in the meantime, the return value is initial.
Latest notes: A different type of reference keeps objects alive until the available memory becomes limited. The class CL_ABAP_SOFT_REFERENCE>> is designed for these soft references>, but this class is currently still implemented like the class CL_ABAP_WEAK_REFERENCE >. ABAP_HINT_END
Example ABAP Coding
A weak reference is set to the object of the object reference variable oref>, and the latter is then deleted. The weak reference points to the object for as long as the garbage collector is not executed. The return value is initial after the explicit call of the garbage collector. ABEXA 00869 ABAP_EXAMPLE_END