‎2006 Jul 21 4:00 PM
I have this situation:
CREATE OBJECT equipo EXPORTING sernr = p_sernr1
matnr = p_matnr1.
CALL METHOD equipo->ingreso_directo_homologado
EXPORTING centro = aux_centro
almacen = ga_pos_entregas-almacen IMPORTING error = error
texto = p_texto.
CREATE OBJECT equipo EXPORTING sernr = p_sernr2
matnr = p_matnr2.
CALL METHOD equipo->ingreso_directo_homologado
EXPORTING centro = aux_centro
almacen = ga_pos_entregas-almacen IMPORTING error = error
texto = p_texto.
Could be that second CREATE OBJECT sentence fails, and second CALL METHOD sentence refers to first object created?
Points guaranteed.
‎2006 Jul 21 4:06 PM
Hi,
I dont think so.
equipo --> this is just a variable which holds the memmory location of the object created during first call.
when u will create another object using same variable ; i think new memmory location ( new object ) will be allocated to the variable.
I will try and confirm the same.
‎2006 Jul 21 4:12 PM
Ok, i agree with you, but what happens if second CREATE OBJECT fails? Holds equipo variable the memmory location of the first object created?
‎2006 Jul 21 4:21 PM
Hi,
I have Test the same ; which i have written above . it working fine.
U can cross check. ( copy paste the code & run it )
Check the value <b>o_alvgrid</b> in debugging mode.
u will fine new refrence for each create object.
DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,
o_custcontainer TYPE REF TO cl_gui_custom_container,
o_custcntr_sum TYPE REF TO cl_gui_custom_container.
CONSTANTS :
lc_custcontrol TYPE scrfname VALUE 'CC_ALV',
lc_custcntr_sum TYPE scrfname VALUE 'CC_ALV_SUM' .
CREATE OBJECT o_custcontainer
EXPORTING
container_name = lc_custcontrol
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_custcontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
CREATE OBJECT o_custcntr_sum
EXPORTING
container_name = lc_custcntr_sum
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_custcontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
write :/ 'ABC'.
<b>As per 2nd post of urs .</b>
i think result will be unpredictable.
initial value of refrence variable are always ...illegal refrence.
it may clear the variable to initial value
or
it may retain the current memmory location.
<b>Reward Points & Mark Helpful Answers</b>
‎2006 Jul 21 4:30 PM
Hi,
if your second CREATE OBJECT sentence fails, nothing will happen to the reference equipo. In consequence, as you assume, the second CALL METHOD still refers to first object created.
You should check the imported error to make sure the second CREATE was successful. Only then you may call method.
As you did not mention what is the class equipo is referenced to (looks like own object), it is hard to say what's happening.
I think in your case it will be OK to check the value of imported error parameter.
Regards,
Clemens
‎2006 Jul 21 5:04 PM
‎2006 Jul 21 5:16 PM
Hi,
If you are using same name to create many instances , system will automatically creates object references. object methods will work based on object references.
i don't think if second 'create object' fails , methods will not refer to the first object.
in debug mode check -> goto->display data object ->object
you can see the instance information
Regards
Appana