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

Reference to a variable

Former Member
0 Likes
527

Hi all,

my question is how to get a reference to a variable which name is dynamically created at runtime?

Example:

lv_varname = part1 && part2.

get reference of (lv_varname) into ref.

I found no possiblity to manage that with the GET REFERENCE statement and I dont want to use FIELD-SYMBOLS.

thx in advance.

Br,

Markus

3 REPLIES 3
Read only

Former Member
0 Likes
490

I think it can't be done without using field symbols.

Read only

0 Likes
490

u can get it with field symbol

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
490

The data object must be either a variable statically declared or a field symbol pointing to some objects( dynamic ).

The possible ways are as below:

DATA:lv_string TYPE char11.

DATA:lv_variable TYPE c VALUE 'X'.

DATA:wf_ref TYPE REF TO data.

FIELD-SYMBOLS:<fs1> TYPE ANY.

FIELD-SYMBOLS:<fs2> TYPE ANY.

lv_string = 'LV_VARIABLE'.

ASSIGN (lv_string) TO <fs1>.

WRITE <fs1>.

  SKIP 1.

  GET REFERENCE OF <fs1> INTO wf_ref.

ASSIGN wf_ref->* TO <fs2>.

WRITE <fs2>.

SKIP 1.

  GET REFERENCE OF lv_variable INTO wf_ref.

ASSIGN wf_ref->* TO <fs2>.

WRITE <fs2>.