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

Reg Dynamic class instance creation

Former Member
0 Likes
888

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
Read only

Former Member
0 Likes
733
Read only

former_member69765
Contributor
0 Likes
733

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.

Read only

narin_nandivada3
Active Contributor
0 Likes
733

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

Read only

Former Member
0 Likes
733

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

Read only

0 Likes
733

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