Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

collect statement

Former Member
0 Kudos
139

What is a collect statement? How is it different from append?

8 REPLIES 8

former_member212005
Active Contributor
0 Kudos
109

Varsha, Search in SDN before posting such a question...

Moreover you could have also used F1 help...

Former Member
0 Kudos
109

Hi Varsha,

Collect statement collect/adds the records based on a key field.

For Eg:

Itab:

F1 F2.

A 10

A 20

B 30

B 40

Collect statement will add the values of 10 and 20 since the Key field is A for both the entry.

Append will append/add a record at the end of existing records.

Thanks.

Mohanraj.N

Former Member
0 Kudos
109

I hope this will clear your idea about the difference between Collect and Append....

**********************************************************************************************

APPEND :

IT IS USED TO GET THE RECORD FROM THE INTERNAL TABLE HEADER TO THE BODY AREA

IT ALLOWS DUPLICATION

COLLECT:

IT IS USED TO A GET A RECORD FROM HEADER TO THE BODY AREA BUT IT WILL NOT ALLOW ANY DUPLICATION EXCEPT IF THERE IS ANY NUMERIC FIELS IT ADDS THAT FIELDS DATA BUT NOT AS A NEW RECORD

OR

If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry.

**********************************************************************************************

Regards,

Mandeep.

Former Member
0 Kudos
109

hi,

Append : creates the new entry in the internal table irrespective of (already) entry with the same key fields.

Collect : If an entry with the same key already exists, the collect statement does not append a new line, but adds the contents of the numeric fields in the work area in the existing entry.

Former Member

kesavadas_thekkillath
Active Contributor
0 Kudos
109

Check the F1 documentation

Former Member
0 Kudos
109

Hi varsha,

Hope this answers your question.

Collect: it adds the numeric fields to the existing non numeric key field records, thereby avoiding duplicate values.

Append : will simply add the records.

Former Member
0 Kudos
109

Hi,

If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry.

Regards,

Jyothi CH.