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

create instance of the class dynamically

i045323
Product and Topic Expert
Product and Topic Expert
0 Likes
2,295

hi,

i receive the class name as a string whose instance has to be created.

and i need to return the instance of the importing class.

Could anybody tell me the Functiom module or the class to achieve this.

may be an appropiate example would be very helpful.

thanks in advance

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Apr 28, 2008 1:18 PM

1 ACCEPTED SOLUTION
Read only

Former Member
1,411
DATA:
classname TYPE seoclsname,
o_ref TYPE REF TO object.
...
CREATE OBJECT o_ref TYPE (classname) PARAMETER-TABLE it_par
EXCEPTION-TABLE it_exc.

The class name must be set in data object classname at runtime. The object reference, o_ref, must be compatible with this class, or typed to a shared superclass or with TYPE REF TO object.

G@urav.

1 REPLY 1
Read only

Former Member
1,412
DATA:
classname TYPE seoclsname,
o_ref TYPE REF TO object.
...
CREATE OBJECT o_ref TYPE (classname) PARAMETER-TABLE it_par
EXCEPTION-TABLE it_exc.

The class name must be set in data object classname at runtime. The object reference, o_ref, must be compatible with this class, or typed to a shared superclass or with TYPE REF TO object.

G@urav.