‎2007 May 24 2:58 PM
Hi everyone,
Here is a code where the object is not really cleared.
CLASS testfree DEFINITION.
PUBLIC SECTION.
METHODS set_var.
METHODS getvar EXPORTING pv_text TYPE char10.
PRIVATE SECTION.
CLASS-DATA : gv_text(10).
ENDCLASS.
CLASS testfree IMPLEMENTATION.
METHOD set_var.
gv_text = 'hello world'.
ENDMETHOD. "set_var
METHOD getvar.
pv_text = gv_text.
ENDMETHOD. "getvar
ENDCLASS. "testfree IMPLEMENTATION
START-OF-SELECTION.
DATA: go_testfree TYPE REF TO testfree,
gv_text1(10).
CREATE OBJECT go_testfree.
CALL METHOD go_testfree->set_var.
CALL METHOD go_testfree->getvar
IMPORTING
pv_text = gv_text1.
WRITE:/ 'before free : ', gv_text1.
FREE go_testfree .
CLEAR gv_text1.
CREATE OBJECT go_testfree.
CALL METHOD go_testfree->getvar
IMPORTING
pv_text = gv_text1.
WRITE:/ 'After free : ', gv_text1.
The problem is that gv_text1 is still set to value 'hello world' after the FREE command.
How is it possible ?
Thanks
Regards.
‎2007 May 24 3:07 PM
I guess declaring it as CLASS-DATA is the problem here
declare that as DATA
DATA : gv_text(10).
‎2007 May 24 3:07 PM
I guess declaring it as CLASS-DATA is the problem here
declare that as DATA
DATA : gv_text(10).
‎2007 May 24 3:09 PM
‎2007 May 24 3:09 PM