1. Requirement
2. Solution.
data:l_field(10) type c.
data l_pos like faglflext-rpmax.
field-symbols: <fs1> type any.
selection-screen begin of block b1 with frame title text-t01.
parameters : p_bukrs like faglflext-rbukrs obligatory memory id bur,"公司
p_ryear like faglflext-ryear obligatory default sy-datum+0(4)."会计年度
select-options:
s_kostl for faglflext-rcntr,"成本中心
s_rpmax for faglflext-rpmax. "期间
selection-screen end of block b1.
loop at lt_item into lw_item.
clear:l_field,l_pos.
l_pos = 1.
do 12 times.
concatenate 'TSL' l_pos+1(2) into l_field.
unassign <fs1>.
assign component l_field of structure lw_item to <fs1>.
if l_pos in s_rpmax.
* unpack l_pos to l_pos.
lw_item-zsum = <fs1> + lw_item-zsum.
else.
<fs1> = 0.
endif.
l_pos = l_pos + 1.
enddo.
collect lw_item into gt_item.
endloop.
3. Summary
Field Symbols is shared memory. Sometimes it is very convient.
|