Ansicht
Dokumentation

ABENC_DESTRUCTOR - C DESTRUCTOR

ABENC_DESTRUCTOR - C DESTRUCTOR

General Data in Customer Master   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

- The C Destructor

A destructor is a special method called that is 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.

For special cases and for internal use only, the special predefined instance method destructor can be declared in the public visibility section of a class:

CLASS class DEFINITION.
  PUBLIC SECTION.
    METHODS destructor $[NOT AT END OF MODE$].
    ...
ENDCLASS.

Currently, only one statement can be used in the implementation of the method destructor:

CLASS class IMPLEMENTATION.
  METHOD destructor.
    SYSTEM-CALL c-destructor 'name' USING attr1 attr2 ...
  ENDMETHOD.
ENDCLASS.

The destructor therefore allows the calling of a C routine name when an object is deleted. The routine must exist in the ABAP kernel so that no syntax error occurs.

If the optional addition NOT AT END OF MODE is used, the destructor is not executed if the internal session is closed regardless. Usually a destructor is also executed at the end of an internal session and should mainly be used to release bound external resources that are not released automatically when the session is closed.

When the C routine is called, attributes attr1, attr2, ... of the class of any complex data type can be passed to this routine. If multiple parameters are to be passed, an appropriate data type must be defined.

During the lifetime of an internal session, the time when the method destructor is executed depends on when Garbage Collector is started. When an internal session is closed, the destructors that are 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.






ROGBILLS - Synchronize billing plans   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 2632 Date: 20240505 Time: 033412     sap01-206 ( 49 ms )