Skip to Content
0
Former Member
Sep 11, 2007 at 09:41 AM

In macro call method of object

340 Views

Hi,

is it possible to call method provides in parameter to macro ?

From the call of my macro i provide object instancied and the name of my method. In my macro i wanted to do : CALL METHOD &1->&2 but it don't work.

I provided you my code which does not function :

REPORT z_erca_test.

----


  • CLASS lcl_ee_data DEFINITION

----


CLASS lcl_ee_data DEFINITION.

PUBLIC SECTION.

METHODS:

get_data_list,

get_data_list_suisse.

ENDCLASS. "lcl_ee_data DEFINITION

----


  • CLASS lcl_ee_data IMPLEMENTATION

----


CLASS lcl_ee_data IMPLEMENTATION.

METHOD get_data_list.

WRITE 'Default'.

ENDMETHOD. "get_data_list

METHOD get_data_list_suisse.

WRITE 'Suisse'.

ENDMETHOD. "get_data_list_suisse

ENDCLASS. "lcl_ee_data IMPLEMENTATION

*----


  • DEFINE MACRO

DEFINE launch.

data: l_method type string.

l_method = 'get_data_list'.

concatenate l_method &2 into l_method separated by '_'.

write l_method.

call method &1->&2.

END-OF-DEFINITION.

*----


START-OF-SELECTION.

DATA : l_ee TYPE REF TO lcl_ee_data.

CREATE OBJECT l_ee.

launch l_ee 'suisse'.