How to convert string to be commnad

Question: Dear Experts
I would like to convert string to be command in abap as my below program I would like <mara> to be command that I assign data to internal table,
Please advise me how to do.

----------------
report zmm_test01 .

data: begin of itab occurs 0,
matnr(10) type c,
date like sy-datum,
qty like mseg-menge,
end of itab.

data: begin of ctab occurs 0,
matnr(10) type c,
end of ctab.

data: begin of xtab occurs 0,
matnr(10) type c,
d27 like mseg-menge,
d28 like mseg-menge,
d29 like mseg-menge,
end of xtab.

start-of-selection.
itab-matnr = 'test'.
itab-date = sy-datum.
itab-qty = 3.
append itab.
clear itab.

itab-matnr = 'test'.
itab-date = sy-datum + 1.
itab-qty = 3.
append itab.
clear itab.
itab-matnr = 'test'.
itab-date = sy-datum + 2.
itab-qty = 4.
append itab.
clear itab.
loop at itab.
ctab-matnr = itab-matnr.
collect ctab.
endloop.

* loop at ctab.
* loop at itab where matnr = ctab-matnr.
* xtab-matnr = itab-matnr.
* CASE itab-date+6(2).
* WHEN 27.
* xtab-d27 = itab-qty.
* WHEN 28.
* xtab-d28 = itab-qty.
* WHEN 29.
* xtab-d29 = itab-qty.
* ENDCASE.
* collect xtab.
* clear xtab.
* endloop.
* endloop.

data x(2) type c.
data dat(20) type c.

loop at ctab.
loop at itab where matnr = ctab-matnr.
xtab-matnr = itab-matnr.
x = itab-date+6(2).
concatenate 'xtab-d' x ' = itab-qty. ' into dat.
field-symbols <mara> type any.
[color=red]* for this below statement <mara> will be command xtab-d27 = itab-qty.
assign dat to <mara>.[/color][color=red]* how to make system understand that it is command code.[/color]
collect xtab.
clear xtab.
endloop.
endloop.

loop at xtab.
write :/ xtab-matnr,
xtab-d27, xtab-d28, xtab-d29 .
endloop.

Answer:
Try
field-symbols <mara> type any.
.
.
.
xtab-matnr = itab-matnr.
x = itab-date+6(2).
concatenate 'xtab-d' x into dat.

assign (dat) to <mara>.
<mara> = itab-qty.

collect xtab.
clear xtab.
.
.
.

You can't assign ABAP code to a field-symbol. Only data and data references.

Regards

m@t
_________________
TULY The quality of answers is roughly proportional to the quality of the question.

The downside of being better than everyone else is that people tend to assume you're pretentious.
Copyright ?2007 - 2008 www.jt77.com