2009 Aug 13 3:18 AM
Hello Experts,
variable v_classname type seoclsname will contain class name 'ZCL_TEST'
and method name will be stored in variable v_cls_mth = 'GET_DATA'
I want to create a object of class ZCL_SAMPLE at run time and once object is created it corresponding method stored in variable v_cls_mth will be called.
Please note that class is implemented in SE24.
i had done something like this:
data:v_classname TYPE seoclsname value 'ZCL_TEST',
v_ref type ref to object.
start-of-selection.
create object v_ref type (v_classname).
call method v_ref->GET_DATA().
Its not working.
Please help me in correcting above code. Many thanks in advance.
- Nilesh
Edited by: Nilesh Pawar on Aug 13, 2009 4:21 AM
2009 Aug 13 5:11 AM
Hello Nilesh
You need to call the method dynamically as well:
data:
gd_classname TYPE seoclsname value 'ZCL_TEST',
gd_method TYPE seoclsname VALUE 'GET_DATA',
go_ref TYPE REF TO object.
start-of-selection.
create object go_ref type (v_classname).
call method go_ref->(gd_method).
Regards
Uwe
2009 Aug 13 5:11 AM
Hello Nilesh
You need to call the method dynamically as well:
data:
gd_classname TYPE seoclsname value 'ZCL_TEST',
gd_method TYPE seoclsname VALUE 'GET_DATA',
go_ref TYPE REF TO object.
start-of-selection.
create object go_ref type (v_classname).
call method go_ref->(gd_method).
Regards
Uwe
2009 Aug 13 6:24 AM
Aaah !!! putting variabe name for method went out of my mind !!!
Thanks Uwe !!
- Nilesh
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |