09-20-2007 2:04 AM
hi,
What is a collect statement? How is it different from append?
regards.
09-20-2007 2:29 AM
Simple example :
Collect - when ever non numeric columns equal then it sums numeric value otherwise it works like append statement.
suppose you have internal table :
data : begin of itab occurs 0,
field1(3) type c, " -> Non numeric
field2 type i, " Numeric
end of itab.
itab-field1 = 'ABC'.
itab-field2 = 100.
collect itab.
itab-field1 = 'ABC'.
itab-field2 = 200.
collect itab.
loop at itab.
write:/ itab-field1,itab-field2.
endloop
output is : ABC 300
Since here collect will look at non numeric then it adds numeric columns.
data : begin of itab occurs 0,
field1(3) type c, " -> Non numeric
field2 type i, " Numeric
end of itab.
itab-field1 = 'ABC'.
itab-field2 = 100.
collect itab.
itab-field1 = 'ABD'.
itab-field2 = 200.
collect itab.
loop at itab.
write:/ itab-field1,itab-field2.
endloop
output is : ABC 100
ABD 200
Here it works like Append statement
I hope you got it
Thanks
Seshu
09-20-2007 2:24 AM
Why are you flooding the forum when most of the answers can be found by searching this forum??
It's only a matter of time when the moderators will notice this and probably ban you from posting here permanently.
09-20-2007 2:29 AM
Simple example :
Collect - when ever non numeric columns equal then it sums numeric value otherwise it works like append statement.
suppose you have internal table :
data : begin of itab occurs 0,
field1(3) type c, " -> Non numeric
field2 type i, " Numeric
end of itab.
itab-field1 = 'ABC'.
itab-field2 = 100.
collect itab.
itab-field1 = 'ABC'.
itab-field2 = 200.
collect itab.
loop at itab.
write:/ itab-field1,itab-field2.
endloop
output is : ABC 300
Since here collect will look at non numeric then it adds numeric columns.
data : begin of itab occurs 0,
field1(3) type c, " -> Non numeric
field2 type i, " Numeric
end of itab.
itab-field1 = 'ABC'.
itab-field2 = 100.
collect itab.
itab-field1 = 'ABD'.
itab-field2 = 200.
collect itab.
loop at itab.
write:/ itab-field1,itab-field2.
endloop
output is : ABC 100
ABD 200
Here it works like Append statement
I hope you got it
Thanks
Seshu