Application Development and Automation 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: 
Read only

collect

Former Member
0 Likes
513

hi all,

CAn we use append statement soon after using collect statement , bcoz i heard tht it reduced performance.Is it true??Plz clarify

regards,

Ganesh

hi all,

CAn we use append statement soon after using collect statement , bcoz i heard tht it reduced performance.Is it true??Plz clarify

regards,

Ganesh

4 REPLIES 4
Read only

Former Member
0 Likes
487

When you write a 'COLLECT' statement it automatically APPENDS the record.

Regards,

Hema

Read only

Former Member
0 Likes
487

There is nothing like that.

BUt you need to append that only if you want a separate internal table with subtptal/totals.

  • Correct way1

loop at itab.

at end of field1.

collect itab into itab2.

append itab2.

clear itab2.

endat.

endloop.

  • Correct way2

loop at itab.

at end of field1.

collect itab.

endat.

endloop.

  • Wrong way.

loop at itab.

at end of field1.

collect itab.

append itab.

endat.

endloop.

Regards,

ravi

Read only

Former Member
0 Likes
487

Hi ganesh,

1. When we use collect, we do not use append, for the same internal table.

2. Collect is a special keyword,

which instead of blindly appending the record,

does some extra intelligent logic.

3. When using collect,

it will first COMPARE all the NON-NUMERIC fields,

from the workarea with the full internal table,

- If no matching is found, then only it will apppend the record.

-- if matching is found, then

it will MODIFY the old record,

and SUM UP / ADD the Numeric values.

regards,

amit m.

Read only

0 Likes
487

COLLECT statement has the same effect as inserting the new line so u not need to write append again. 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.

You should only use the COLLECT statement if you want to create summarized tables. If you use other statements to insert table entries, you may end up with duplicate entries.

GO THROUGH THIS LINK

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/collect.htm