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: 

For All entries or Loop

Former Member
0 Kudos

Hi All,

I have an internal table with around > 50000 to 100 000 employee records.

like pernr, etc etc.

I have to bring other data from 10 tables for the records in this internal table.

now, which one would be better to use, For all entries or Loop.

I am using For all entries, but seriously doubt whether loop would be better or for all entries in this scenario.

Suggestions appreciated.

Thanks in Advance,

Mohan

1 ACCEPTED SOLUTION

former_member194613
Active Contributor
0 Kudos

You should specify your problem in more detail, 100.000 records is a lot.

I guess that you have the table with 100.000 records and you want to add information of the other database tables to this table or to independent other internal tables? In the first case, the FOR ALL ENTRIES must combine the different tables with the large employee table, therefore it is not straightforward, which version is faster.

Are some of the db tables buffered? If yes, then simply use select ... endselect inside the loop.

Will you read also up 100.000 different records from the other tables, or are sometimes much less, i.e. many employees have the same entries in some tables?

Can you use joins for some of the tables.

I would not rely on guessing, but try both versions. Use command GET RUNTIME and measure the version with LOOP ... ENDLOOP and the version with FOR ALL ENTRIES.

Siegfried

8 REPLIES 8

Former Member
0 Kudos

Hi,

FOR ALL ENTRIES is better, if you look at the Performance wise then use the for all entries ....

Regards

Sudheer

Former Member
0 Kudos

Hi Mohan,

If the records which u wanted to bring are in database then you can go for FOR ALL ENTRIES and if they are in internal tables thn you can go for LOOP ...... ENDLOOP.

Regards,

Ravi

Former Member
0 Kudos

Hi,

Use FOR ALL entries instead of LOOP and also before using FOR ALL entries sort the internal table by field for which you want to fetch the data from 10 tables.

which would give better performance.

former_member194613
Active Contributor
0 Kudos

You should specify your problem in more detail, 100.000 records is a lot.

I guess that you have the table with 100.000 records and you want to add information of the other database tables to this table or to independent other internal tables? In the first case, the FOR ALL ENTRIES must combine the different tables with the large employee table, therefore it is not straightforward, which version is faster.

Are some of the db tables buffered? If yes, then simply use select ... endselect inside the loop.

Will you read also up 100.000 different records from the other tables, or are sometimes much less, i.e. many employees have the same entries in some tables?

Can you use joins for some of the tables.

I would not rely on guessing, but try both versions. Use command GET RUNTIME and measure the version with LOOP ... ENDLOOP and the version with FOR ALL ENTRIES.

Siegfried

Former Member
0 Kudos

Thank you Siegfried,

Yes, there might be equal number records in the other tables as well.

I am going bring them into 10 different internal tables, using the PERNR in this master table as key and then move the entire data into a final internal table to send to ALV grid.

The employee details in the first table is being stored in a SORT table, do u still think we need to explicitly run the SORT command?

former_member194613
Active Contributor
0 Kudos

if pernr is the key then you should definitely use hashed tables, if you go to sizes of more than 10.000 lines.

Try to use joins on some of 10 DB tables.

Check buffer setting, buffered tables should not be used with FOR ALL ENTRIES but directly inside the LOOP

SELECT ...

INTO itab2

FOR ALL ENTRIES IN itab_0

....

LOOP AT itab0

SELECT .... buffered tables

READ itab2 ...

modify itab0 or append itab_new

ENDLOOP

Former Member
0 Kudos

Hi

FOR ALL ENTRIES is the better way to use other than LOOP

beacuse getting data from that 10 tables is difficult by useing LOOP

you need to LOOP for every record

If you use FOR ALL ENTRIES then it will give the total selection at one time

FOR ALL ENTRIES is the best way than the LOOP

<b>Reward if usefull</b>

Former Member
0 Kudos

Hi Mr:Mohan,

Let your current data in ITAB1(100000records).

Now u have to fetch data from diffrent data base tables correspondingly. Here you must use FOR ALL ENTRIES Of ITAB1.

One Important think you must notice is whenever you use FOR ALL ENTRIES of ITAB1, u must check whether ITAB1 is intial or not.Because if ITAB1 is initial it will pull all the detaisl from data bases which will reversely affect performance.

Another pre-requisite is <b>sort itab1</b> with fileds which you are using for selection, which will also increase the performance.

Regards,

Incase of any doubt regarding this you can ask me.

reward if find useful!

Antony Thomas