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

Dinamic Definition

Former Member
0 Likes
431

Hi. I have the next problem.

Let' supose that I have a variable wich contents the name of a data element (ls_element = NAME_ORG).

I want to define another variable using the content of the previus variable (ls_variable TYPE NAME_ORG).

How can I do that??

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
407

Hello,

try using the CREATE DATA statement:


DATA type_name TYPE TYPENAME.
DATA dyn_data TYPE REF TO DATA.

* Dynamically create the variable dyn_data
type_name = 'VBAK'.               " <-- or any other valid type
CREATE DATA dyn_data TYPE (type_name).

Use a field symbol to work with the dynamically defined variable.

Best regards

David

2 REPLIES 2
Read only

Former Member
0 Likes
408

Hello,

try using the CREATE DATA statement:


DATA type_name TYPE TYPENAME.
DATA dyn_data TYPE REF TO DATA.

* Dynamically create the variable dyn_data
type_name = 'VBAK'.               " <-- or any other valid type
CREATE DATA dyn_data TYPE (type_name).

Use a field symbol to work with the dynamically defined variable.

Best regards

David

Read only

Former Member
0 Likes
407

Hi,

Firstly, you can get NAME_ORG into one variable using ((ls_element).. like..

lv_temp = ((ls_element).

Once you get this.. use CREATE DATA.. to create lv_variable.