11-24-2020 4:57 AM
Hai,
When we have created an Object in OOABAP, how to delete the object because of reusability?
11-24-2020 6:29 AM
11-24-2020 7:14 AM
Object means nothing, just the usage of Class/Interface in programming.
So, there is:
- Class: those you can create in SE24
- Instance: When you use these class using code like my_instance = new my_class( ).
Delete a class, is suppress the class in SE24.
For Instance, it is more complex. You cannot really delete an instance, you just delete the reference to this instance.
my_instance = new my_class( ).
my_instance is a reference to the instance created based on my_class.
so if you want to have my_instance link to a new instance, you could use FREE.
But ! it will not delete the first instance, just delete the reference to this first instance.
11-24-2020 9:42 AM
11-24-2020 10:30 AM
You wont directly delete an instance, it will be deleted by garbage collector once its last reference and every event handler is removed by an explicit clear (or free) statement or an implicit end of lifetime.
NB: You could eventually use method CL_ABAP_MEMORY_UTILITIES=>DO_GARBAGE_COLLECTION, but should not usually be required.
11-24-2020 12:17 PM
I saw this one, but I never try
METHOD destructor.
SYSTEM-CALL c-destructor 'name' USING attr1 attr2 ...
ENDMETHOD.
11-24-2020 3:27 PM
More information on Abap handling of destructor methods can be found in 168703 - Destructors in ABAP Objects - ... In light of all these problems, the designers of ABAP Objects decided no not provide an ABAP Destructor at this time. Instead, there is a provision for a 'C-destructor' that can however only be used by SAP kernel developers...
12-06-2020 3:55 AM
Like It should be deleted permanently. we cannot use the object in some other place.