Skip to Content
0
Jun 02, 2016 at 02:55 PM

How to run the content of a string variable

58 Views

Hi,

I have a table in which there are eight field with this name:

COLOR1, COLOR2,.....COLOR8

In order to improve the code I would like to do a loop which will execute 8 times and will get the value of the eight fields.

I think the code would be somethig like this.

DATA : MYSUM TYPE I.

DATA : MYSTR(30) TYPE C.

CLEAR MYSUM.

DO 8 TIMES.

CLEAR MYSTR.

CONCATENATE "MYTABLE-COLOR" SY-INDEX INTO MYSTR.

MYSUM = MYSUM + MYSTR.

ENDDO.

And my question is whether it is possible to get the value of MYSTR in each loop (MYTABLE-COLOR1, MYTABLE-COLOR2....)?

Thanks a lot.