‎2008 Jan 16 7:01 PM
Hi Experts,
I am getting the error as " the method get_data has no returning parameter.
Can someone please help me with this.
CLASS main DEFINITION.
PUBLIC SECTION.
METHODS add_data IMPORTING i_data TYPE i.
METHODS get_data EXPORTING e_data TYPE char20.
PRIVATE SECTION.
DATA attribute TYPE char01.
ENDCLASS.
----
CLASS main IMPLEMENTATION
----
CLASS main IMPLEMENTATION.
METHOD add_data.
ADD i_data TO attribute.
ENDMETHOD.
METHOD get_data.
CONCATENATE 'Attribute value' attribute
INTO e_data SEPARATED BY space.
ENDMETHOD.
ENDCLASS.
DATA: object_reference TYPE REF TO main.
end-of-selection.
CREATE OBJECT object_reference.
DATA:
var TYPE char20.
CALL METHOD object_reference->add_data( i_data = 3 ).
var = object_reference->get_data( ). --> errored here
WRITE var.
‎2008 Jan 16 7:08 PM
Hi Dan, if you want to use a RETURNING parameter when you call you method, you need to define the parameter as a RETURNING parameter in your class definition.
METHODS get_data RETURNING VALUE(e_data) TYPE char20.
You had defined it as an EXPORTING parameter, which means that when you call the method you would have need to use this syntax instead.
object_reference->get_data( IMPORTING e_data = var ).
Regards,
Rich Heilman
‎2008 Jan 16 7:08 PM
Hi Dan, if you want to use a RETURNING parameter when you call you method, you need to define the parameter as a RETURNING parameter in your class definition.
METHODS get_data RETURNING VALUE(e_data) TYPE char20.
You had defined it as an EXPORTING parameter, which means that when you call the method you would have need to use this syntax instead.
object_reference->get_data( IMPORTING e_data = var ).
Regards,
Rich Heilman
‎2008 Jan 16 7:20 PM
Hi Rich,
I still want to use exporting param as :
METHODS get_data exporting e_data TYPE char20.
-
-
-
and called the method as u suggested it is throwing an error saying " statement object_reference->get_data( is not defined ".
Can you please suggest?
Thanks
Dany
‎2008 Jan 16 7:26 PM
H Dan, if you would like to use the EXPORTING parameter, then you must write you method call like this.
object_reference->get_data( importing e_data = var ).
If you are on an earlier release, then you must use the CALL METHOD as well.
CALL METHOD object_reference->get_data( importing e_data = var ).
Regars,
Rich Heilman