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

Get variable type dynamically ?

Former Member
0 Likes
545

Hi,

i want to get type of a variable dynamically, in ABAP. For example, the following code :

data: my_var type zmystruct.

In ABAP i want to get 'zmystruct', and after i want to create dynamically a new variable with this type.

Thanks for help.

Cheers

ps: I posted yesterday the same message but it was deleted, why ?

1 ACCEPTED SOLUTION
Read only

Former Member
3 REPLIES 3
Read only

Former Member
Read only

michael-john_turner
Active Participant
0 Likes
500

Hi,

The easiest way is to use class CL_ABAP_TYPEDESCR. It will return all the details of a variable (including complex types), allowing you to dynamically create another instance of it.

MJ

Read only

Former Member
0 Likes
500
DATA: FLD(8) TYPE N, 
      F_TYPE. 
DESCRIBE FIELD FLD TYPE F_TYPE. 



Result: F_TYPE contains the value 'N'.

Reward if helpful and close the thread

Message was edited by:

chandrasekhar jagarlamudi