2008 Oct 31 11:41 AM
Dear Colleagues !
In an FM I build a tree for the class CL_COLUMN_TREE_MODEL. It works fine. But this class doesn't have a destructor method for the tree (I want to use it at exit from the FM). Do You know a solution for it ? Is there an FM for destroying the address room after calling this FM (it would be a solution too - if I call this FM more times in the same program).
Thanks a lot for Your help and kind regards
Peter
Moved by moderator to correct forum
2008 Oct 31 1:58 PM
Simply do the following:
lo_column_tree->free( ).
clear lo_column_tree.
lo_column_tree_container->free( ).
clear lo_column_tree_container.
The "free" frees the GUI control on the SAP GUI.
Regards,
Thomas
Simply do the following:
lo_column_tree->free( ).
clear lo_column_tree.
lo_column_tree_container->free( ).
clear lo_column_tree_container.
The "free" frees the GUI control on the SAP GUI.
Regards,
Thomas
2008 Oct 31 1:38 PM
ABAP does not know the concept of destructors, instead it has the garbage collector, which destroys any object which is no longer referenced. Thus all you have to do is:
1.) call the control framework method "free"; clear the object reference variable of your cl_gui_column_tree.
Regards,
Thomas
2008 Oct 31 1:56 PM
Hi Thomas,
the variable, which I want to destroy, is defined with reference to CL_COLUMN_TREE_MODEL.
I want to destroy it: FREE OBJECT gw_tree, but I get a syntax error: variables with references cann't be destroyed with FREE.
Do You know perhaps another solution ?
Regards Peter
2008 Oct 31 3:14 PM
>
> Hi Thomas,
>
> the variable, which I want to destroy, is defined with reference to CL_COLUMN_TREE_MODEL.
>
> I want to destroy it: FREE OBJECT gw_tree, but I get a syntax error: variables with references cann't be destroyed with FREE.
>
> Do You know perhaps another solution ?
>
> Regards Peter
What you are wanting to do is destroy the object refered to by the object reference variable - not the object reference variable itself. When an object on the heap no longer has any object reference variables assigned to it, then it will be collected (at some undefined time) by the garbage collector.
So,
CREATE gw_tree.
* do stuff
CLEAR gw_treewill mean no more references to the object created by the CREATE, so the memory the object is using will be reclaimed.
matt
2008 Oct 31 1:58 PM
Simply do the following:
lo_column_tree->free( ).
clear lo_column_tree.
lo_column_tree_container->free( ).
clear lo_column_tree_container.
The "free" frees the GUI control on the SAP GUI.
Regards,
Thomas
2008 Oct 31 2:49 PM
Hi Thomas,
I make the followings:
class lcl_tree definition inheriting from CL_COLUMN_TREE_MODEL.
...
data: G_TREE TYPE REF TO lcl_TREE,
...
CREATE OBJECT G_TREE
EXPORTING
...
These codes are OK.
At exit I want make:
MODULE exit INPUT.
CALL METHOD g_tree->free().
clear: g_tree.
leave to screen 0.
ENDMODULE. " exit INPUT
but I get the error:
"Die Methode "FREE()" ist unbekannt bzw. PROTECTED oder PRIVATE."
I make anything false ...
Do You have an idea ?
Thanks a lot Peter
2008 Oct 31 3:05 PM
First try to free the Tree object and than free the Container object.
Like this:
data o_tree type ref to cl_column_tree_model.
data o_container type ref to cl_gui_custom_container.
MODULE EXIT.
if not o_tree is initial.
clear o_tree.
free o_tree.
endif.
if not o_container is initial.
call method o_container->free.
free o_container.
endif.
ENDMODULE.
Regards,
Naimesh Patel
2008 Oct 31 3:34 PM
In your column tree model you somewhere create a tree control and a container for that control, i.e. you call the method "create_tree_control" and you are exporting the container for the control and you get back an object of type cl_gui_control. On this object you call the "free" method. After you freed the control you have to free also the container. The model itself is cleared by clead lo_tree_model.
Regards,
Thomas
2008 Oct 31 3:57 PM
Hi Naimesh Patel, hi Thomas !
Thank You for helping ! I took the proposal of Naimesh Patel (it comes earlier), and it works fine !!!
I will open another thread in this forum, please check it too !
Thanks a lot and kind regards
Peter
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |