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: 

About Collect statement

Former Member
0 Kudos

what is Collect statement? why this is used?

Message was edited by:

ABHIJEET PADWAL

1 ACCEPTED SOLUTION

KKilhavn
Active Contributor
0 Kudos

Here is a step-by-step guide

1. Log in to a SAP system

2. Go to transaction SE38

3. Type ZZTEST_ABHIJEET

4. Press the button labelled Create (English login, probably other label if you log on in a different language)

5. Type COLLECT

6. Select text COLLECT

7. Press F1.

Don't hesitate to ask again, we are all here to explain how you can read SAP help information...

Kjetil Kilhavn (Vettug AS) - ABAP developer since Feb 2000
2 REPLIES 2

KKilhavn
Active Contributor
0 Kudos

Here is a step-by-step guide

1. Log in to a SAP system

2. Go to transaction SE38

3. Type ZZTEST_ABHIJEET

4. Press the button labelled Create (English login, probably other label if you log on in a different language)

5. Type COLLECT

6. Select text COLLECT

7. Press F1.

Don't hesitate to ask again, we are all here to explain how you can read SAP help information...

Kjetil Kilhavn (Vettug AS) - ABAP developer since Feb 2000

former_member194613
Active Contributor
0 Kudos

I do not know in which system the report ZZ_TEST .... is available, definitely not in every system.

The question is answered with the ABAP online help, use 'i' type in collect, please read all details there.

Basicly the collect statement is used to built up a new internal table with a unique key from another table or moire tables. For lines with identical keys the numerical values are summed up in the new table, assume you have a table

A with key1 key2 valuefield1 with lines

a a 1

a b 3

b a 2

b b 5

But then you are sums of the valuefield1 with identical key1 values, the collect give

a 4

b 7

The collect works faster than doing it by yourself. But never change the new table in the same loop where the collect is executed. The table change will destroy the implicit hashed key, which makes the collect then very slow.

Siegfried