Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

creating same instance again

Former Member
0 Likes
810

Hi ,

I have the following code.

DATA: r_plane TYPE REF TO lcl_airplane,

CREATE OBJECT r_plane EXPORTING im_name = 'LH Berlin'

                                   im_planetype = 'A321'.


CREATE OBJECT r_plane EXPORTING im_name = 'LH Frankfurt'

                            im_planetype = '747-400'.


Here both the object instance name is r_plane ...Does this mean that ABAP will internally create two objects with the same reference "r_plane"


Or will it just overwrite the existing instance.





1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
766

Hi Hema,

ABAP will overwrite the first reference with the second reference  in r_plane, since you are using the same reference Variable. ie., r_plane contains reference to new parameters of LH-FRANKFRUT and planetype 747-400.

Old reference gets overwirted.

Regards,

Ravikiran.K

5 REPLIES 5
Read only

rosenberg_eitan
Active Contributor
0 Likes
766

Hi,

One of the nicest thing about this profession is that we can try things without killing any one in the process....

Do a test....

Regards.

Read only

Former Member
0 Likes
766

After second instance creation, first one will enter zombie/limbo state. It will exist for a while, without having any way to interact with us because of lack of reference, and finally it will be gobbled up by the garbage collector.

Read only

0 Likes
766

Hi,

zombie/limbo state mmmmm...... this is new...

Regards.

Read only

matt
Active Contributor
0 Likes
766

Brains.... need brains....

Read only

Former Member
0 Likes
767

Hi Hema,

ABAP will overwrite the first reference with the second reference  in r_plane, since you are using the same reference Variable. ie., r_plane contains reference to new parameters of LH-FRANKFRUT and planetype 747-400.

Old reference gets overwirted.

Regards,

Ravikiran.K