2007 May 22 7:55 PM
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 ?
2007 May 22 8:05 PM
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 ?
2007 May 22 8:05 PM
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
2007 May 22 8:06 PM
B/c you declared it in a DATA statement... but then never assigned any value to it.
2007 May 22 8:07 PM
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
2007 May 22 8:08 PM
Just change your second ASSIGN statement to a simple = as below.
Change this
assign 'TESTTTTT' to <fs1>.
To this
<fs1> = 'TESTTTTT'.
2007 May 22 8:15 PM
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
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |