The C Destructor
A destructor is a special method called automatically when an object is deleted. Destructors can be used to release resources used by the object that are not covered by garbage collection. Currently, ABAP Objects does not have a destructor in which a regular ABAP processing block can be programmed.
internal use only
CLASS class DEFINITION.
METHODS destructor [NOT AT END OF MODE].
Only one statement can currently be used in the implementation of the method
CLASS class IMPLEMENTATION.
SYSTEM-CALL c-destructor 'name' USING attr1 attr2 ...
This means that the destructor makes it possible to call a C routine name when an object is deleted. The routine must exist in the ABAP kernel so that no syntax error occurs.
If used, the optional addition
NOT AT END OF MODE dictates that the destructor is not executed if the
internal mode is closed
regardless. Usually a destructor is also executed at the end of a mode and should mainly be used to release bound external resources that are not released automatically when the mode is closed.
When the C routine is called, an attribute
... of the class of any complex data type can be passed to the routine. If multiple parameters are passed, an appropriate data type must be defined.
During the lifetime of an internal mode, the time when the method
destructor is executed depends on when
is started. When an internal mode is closed, the destructors not declared using the addition NOT
AT END OF MODE are executed for all objects. In cases of inheritance, the destructors of the subclasses are executed before the destructors of the superclasses.