report.
data: begin of itab occurs 0,
field1 type c,
field2 type c,
value type i,
end of itab.
itab-field1 = 1.
itab-field2 = 1.
itab-value = 2.
append itab.
itab-field1 = 1.
itab-field2 = 1.
itab-value = 2.
append itab.
itab-field1 = 1.
itab-field2 = 2.
itab-value = 2.
append itab.
data: l_sum(2) type c.
data: l_curr type string, "当前行内容
l_pre type string. "上一行内容
loop at itab.
concatenate itab-field1 itab-field2 into l_curr.
if l_curr <> l_pre and sy-tabix <> 1.
write:/ '总和:', l_sum,'处理内容:',l_pre.
clear l_sum.
l_pre = l_curr.
elseif sy-tabix = 1.
l_pre = l_curr.
endif.
l_sum = l_sum + itab-value.
at last.
write:/ '总和:', l_sum,'处理内容:',l_pre.
clear l_sum.
endat.
endloop.
评论