Original post address: http://qiqeloveyou.blogbus.com/logs/28574615.html
Copyright Notice
: During reprinting, please use hyperlinks to indicate the original source and author information of the article and this statement
Http://qiqeloveyou.blogbus.com/logs/28574615.html
Collect statements are embedded in
Select --- endselect
Used in
,
In
Frequently Used in report development
,
The role is based on
Table
Of
Unique
Key,
Automatically accumulate other fields in the table
,
It is generally used to aggregate some data.
Statistics
.
Example:
Data: Begin of mytable,
Keyfield
Like XXX,
Fliedl1
Like
XXX,
Field2
Like XXX,
End of mytable.
Data:
Mytable_col like hashed table of mytable
With
Unique key keyfield with headline.
Select keyfield fliedl1 field2 from
Table_system
Into (mytable-
Keyfield, mytable-fliedl1, mytable-field2 ).
Collect mytable into mytable_col.
Endselect.
The purpose of this example is
Keyfield
Is the primary key
,
Set
Fliedl1
And
Fliedl2
Of
Accumulate data
,
Computing belongs to each
Keyfield
Of
Fliedl1
And
Fliedl1
Of
Sum
.
Collect
Enable
There are two conditions
:
<! -- [If! Supportlists] --> 1.
<! -- [Endif] --> tired
The time when the table is added to must be
Hashed table
Or
Sorted
Table,
That is, you must have a unique
Key.
<! -- [If
! Supportlists] --> 2.
<! -- [Endif] -->
Key
Of
Other attributes must be font-shaped
,
Can be accumulated
.
Of course
Mytable
And
Mytable_col.
Of
The table types must be completely consistent.
.
When a general report is generated
Need to calculate a large amount of data
,
Use
Collect
Language
The advantage of a sentence is that you do not need to retrieve the data locally.
Loop
Accumulate
,
Drop
Low report pressure on the System
.