Application Development 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: 

Reg Dynamic class instance creation

Former Member
0 Kudos

Hi all,

I want to create a instance for a class inside the program, but i know class name dynamically that reside inside a table.

select Classname from <table name> into <classname>.

create object <classname>->variable that got form select query.

we have any alternative solution for this.

Reg,

Hariharan

5 REPLIES 5

Former Member
0 Kudos

former_member69765
Contributor
0 Kudos

Hi,

You can create object of a class at run time by

CREATE OBJECT lref_obj TYPE (lv_class_name).

This tutorial might help : [Dynamic Programming|http://www.abaplearning.com/abap-tutorials/dynamic-programming]

Regards,

Varun.

narin_nandivada3
Active Contributor
0 Kudos

Hi Hariharan,

Please check this Blog By Horst Keller

[Dynamic ABAP Objects|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1944] [original link is broken] [original link is broken] [original link is broken];

Hope this would solve your issue.

Good luck

Narin

Former Member
0 Kudos

hi guys,

what ever you guys told is correct but in the create object the instance name of which type.

CREATE OBJECT L_INST_ASY_CALL

TYPE

(LV_CONTROL).

data: L_INST_ASY_CALL type <?>.

reg,

hari

0 Kudos

Hi Hariharan,


DATA: 
   L_INST_ASY_CALL TYPE REF TO OBJECT.

As the type of L_INST_ASY_CALL is known in runtime so declare it as of type OBJECT.

Hope this would help you.

Good luck

Narin