‎2007 Nov 13 10:51 PM
I don´t understand the next paragraph (help SAP Library)
Is there a error? CREF1 to
CREF3
?CREF1 to CREF2
. As a result, the reference in CREF3 also points to the object C_COUNTER<1>. No more references point to the object C_COUNTER<2>, and it is automatically deleted by the garbage collection. The internal name C_COUNTER<2> is now free again."‎2007 Dec 03 4:54 PM
escuse me, the link is :
<a href="http://help.sap.com/saphelp_nw70/helpdata/en/73/f6b832b3fd11d194f20000e8353423/content.htm">http://help.sap.com/saphelp_nw70/helpdata/en/73/f6b832b3fd11d194f20000e8353423/content.htm</a>
‎2007 Dec 03 4:54 PM
escuse me, the link is :
<a href="http://help.sap.com/saphelp_nw70/helpdata/en/73/f6b832b3fd11d194f20000e8353423/content.htm">http://help.sap.com/saphelp_nw70/helpdata/en/73/f6b832b3fd11d194f20000e8353423/content.htm</a>
‎2007 Dec 03 5:16 PM
I think there isn't any error.
I have tried to explain this.
start-of-selection.
CREATE OBJECT: cref1, cref2.
" creates CREF1 .. value = {O:3*PROGRAM=ZTEST_NPCLASS=C1} - first reference
" creates CREF2 .. vlaue = {O:4*PROGRAM=ZTEST_NPCLASS=C1} - second reference
" CREF3 .. value = *** illegal reference ***
move cref2 to cref3.
" creates CREF1 .. value = {O:3*PROGRAM=ZTEST_NPCLASS=C1}
" creates CREF2 .. vlaue = {O:4*PROGRAM=ZTEST_NPCLASS=C1}
" CREF3 .. value = {O:4*PROGRAM=ZTEST_NPCLASS=C1}
" Values of the CREF3 has been set from CREF2 even if we have definition like DATA: cref3 like cref1.
clear cref2.
" CREF2 .. VALUE = *** illegal reference ***
" CREF3 .. VALUE = {O:4*PROGRAM=ZTEST_NPCLASS=C1}
" second reference is not yet free because CREF3 is holding that
cref3 = cref1.
" creates CREF1 .. value = {O:3*PROGRAM=ZTEST_NPCLASS=C1}
" creates CREF2 .. VALUE = *** illegal reference ***
" CREF3 .. value = {O:3*PROGRAM=ZTEST_NPCLASS=C1}
" second reference is free now.. so, garbage collector will take care of it
write: 'bye'.Regards,
Naimesh Patel
‎2007 Dec 04 9:03 AM
Hi abapers,
thank you for you attention.
I have debuger the next code:
REPORT zcu04_prueba.CLASS counter DEFINITION.
PUBLIC SECTION.
DATA A TYPE I.
METHODS: increment.
ENDCLASS.CLASS counter IMPLEMENTATION.
METHOD increment.
A = A + 1.
ENDMETHOD.
ENDCLASS.START-OF-SELECTION. DATA: cref1 TYPE REF TO counter,
cref2 TYPE REF TO counter,
cref3 LIKE cref1.1º):
cref1 = 0<>
cref2 = 0<>
cref3 = 0<>
CREATE OBJECT: cref1, cref2.2º):
cref1 = 9
MOVE cref2 TO cref3.3º):
cref1 = 9
CLEAR cref2.4º):
cref1 = 9
cref3 = cref1.4º):
cref1 = 9
http://help.sap.com/saphelp_nw70/helpdata/en/73/f6b832b3fd11d194f20000e8353423/content.htm
I don´t understand the next sentence (help SAP Library)
"
The effect of the assignment statement is to copy the reference from CREF1 to CREF2
. As a result, the reference in CREF3 also points to the object C_COUNTER<1>. No more references point to the object C_COUNTER<2>, and it is automatically deleted by the garbage collection. The internal name C_COUNTER<2> is now free again."The effect of the assignment statement is to copy the reference from CREF1 to CREF3
is the correct.Why it is no correct?
Thanks.
Cordial greetings
‎2007 Dec 04 9:07 AM
Hello Lopez
You are right. There is obviously a mistake in the description of the sample.
Regards
Uwe
‎2007 Dec 03 5:10 PM
Hello Lopez
To clarify the question I have pasted the coding here:
DATA: cref1 TYPE REF TO c_counter,
cref2 TYPE REF TO c_counter,
cref3 LIKE CREF1.
CREATE OBJECT: cref1, cref2. " 'pointers' for both instances exist
MOVE cref2 TO cref3. " cref2 and cref3 point to the same instance
CLEAR cref2. " cref3 still filled -> still pointers to both instances exist
cref3 = cref1. " cref3 points no longer to instance<2> but instance<1>
" Thus, there is no pointer to instance<2> anymore
" instance<2> will be removed by garbage collectorRegards
Uwe