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

Placeholder for variable

Former Member
0 Likes
708

Hi!

I need a <b>placeholder for my variable</b>, and this is the situation:

Output fields on screen: OUT1, OUT2, etc. Instead of hard-coding

OUT1 = 'some_text'.
OUT2 = 'some_text'.

...can I use a placeholder for the variable name of the itself, e.g.

data: fieldname(4) value 'OUTX', sytabix(1).

loop at i_text.

sytabix = sy-tabix.
move sytabix to fieldname+3(1). "OUT1, OUT2, OUT3 etc.

<fieldname> = i_text-text. "meaning OUT1 | OUT2... = i_text-text.

endloop.

Thanks for all help!

- Mari Virik

4 REPLIES 4
Read only

Former Member
0 Likes
647

You can use FIELD-SYMBOLS. Together with CONCATENATE (to create fieldname) you should be able to do it.

Read only

0 Likes
647

Hi!

Thank you for your advice

I have tried to use <fs>, but I can't seem to get it quite right... Perhaps you can give me a code example?

- Mari Virik

Read only

0 Likes
647

field-symbols : <fs>.

data : begin of t_out occurs 0,

f1(5),

end of t_out.

data : begin of fl_name,

x1(7) value 't_out-f',

x2(1) type n,

end of fl_name.

t_out-f1 = 'AA1'.

append t_out.

t_out-f1 = 'AA2'.

append t_out.

t_out-f1 = 'AA3'.

append t_out.

loop at t_out.

fl_name-x2 = sy-tabix.

assign (fl_name) to <fs>.

write 😕 fl_name, <fs>.

endloop.

Read only

Former Member
0 Likes
647

Thanx!