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

Field Symbol

Former Member
0 Likes
681

Hi !

I want to do a dynamic assignment for a variable. I want to assign to variable L_AUX1 a value, but the output is empty.

Any ideas?


REPORT  Z_output.

  data: L_AUX1(50),
        L_AUX2(50).
  FIELD-SYMBOLS: <fs1>.

  L_AUX2 = 'L_AUX1'.

  assign (L_AUX2) to <fs1>.
  write :/ sy-subrc.

  assign 'TESTTTTT' to <fs1>.
  write :/ sy-subrc.

  write :/ 'FS:  ',<fs1>.
  write :/ 'AU1: ',L_AUX1.
  write :/ 'AU2: ',L_AUX2.

The output is as follows:

0

0

FS: TESTTTTT

AU1:

AU2: L_AUX1

I want L_AUX1 to have the value ' TESTTTTT' (obviously in a dynamic way!) Why is it empty ?

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
663

If you are trying to assign a value to L_AUX1, then change your code like this.

report  z_output.

data: l_aux1(50),
      l_aux2(50).
field-symbols: <fs1>.

l_aux2 = 'L_AUX1'.

assign (l_aux2) to <fs1>.
write :/ sy-subrc.

 <fs1> = 'TESTTTTT'.      "<---- RIGHT HERE
write :/ sy-subrc.

write :/ 'FS:  ',<fs1>.
write :/ 'AU1: ',l_aux1.
write :/ 'AU2: ',l_aux2.

Regards,

RIch Heilman

Hi !

I want to do a dynamic assignment for a variable. I want to assign to variable L_AUX1 a value, but the output is empty.

Any ideas?


REPORT  Z_output.

  data: L_AUX1(50),
        L_AUX2(50).
  FIELD-SYMBOLS: <fs1>.

  L_AUX2 = 'L_AUX1'.

  assign (L_AUX2) to <fs1>.
  write :/ sy-subrc.

  assign 'TESTTTTT' to <fs1>.
  write :/ sy-subrc.

  write :/ 'FS:  ',<fs1>.
  write :/ 'AU1: ',L_AUX1.
  write :/ 'AU2: ',L_AUX2.

The output is as follows:

0

0

FS: TESTTTTT

AU1:

AU2: L_AUX1

I want L_AUX1 to have the value ' TESTTTTT' (obviously in a dynamic way!) Why is it empty ?

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
664

If you are trying to assign a value to L_AUX1, then change your code like this.

report  z_output.

data: l_aux1(50),
      l_aux2(50).
field-symbols: <fs1>.

l_aux2 = 'L_AUX1'.

assign (l_aux2) to <fs1>.
write :/ sy-subrc.

 <fs1> = 'TESTTTTT'.      "<---- RIGHT HERE
write :/ sy-subrc.

write :/ 'FS:  ',<fs1>.
write :/ 'AU1: ',l_aux1.
write :/ 'AU2: ',l_aux2.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
663

B/c you declared it in a DATA statement... but then never assigned any value to it.

Read only

Former Member
0 Likes
663

Hi,

You have declared the variable L_AUX1 but not assigned any value. hence it is empty.

try the below code.

L_AUX1 = 'testing'.

assign (L_AUX1) to <fs1>.

write 😕 'Value in variable L_AUX1 is ', <fs1>.

thanks,

sksingh

Read only

Former Member
0 Likes
663

Just change your second ASSIGN statement to a simple = as below.

Change this

assign 'TESTTTTT' to <fs1>.

To this

<fs1> = 'TESTTTTT'.

Read only

Former Member
0 Likes
663

Look what your code is actually doing:

1 - You give L_AUX2 the value 'L_AUX1' .

2- Then you assign the Field Symbol and write the return code 0.

It is correct because the return code 0 means that it was correctly assigned.

3- Then you assign 'TESTTTTT' to <fs1>.

<fs1> receives the value 'TESTTTTT' and again you write the return error code ( 0 ) wich is correct.

4- Then you wirte <FS1> hat has the value TESTTTTT.

5- Write L_AUX1 that has no value.

6- write L_AUX2 that has the value 'L_AUX1'.

Any question?

Reward with points if helpul.

Regards