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

Performance issue

Former Member
0 Likes
772

Hello All,

Can anyone tell me which is alternate option for select query <b>For all entries in [itab]</b> where ...

Regards,

Dilip

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
565

Yes, you can loop at the first internal table and do a select statement in the loop.



Loop at itab.

* Do Select here and whatever else you
* need to do with the data.

endloop.


Regards,

Rich Heilman

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
566

Yes, you can loop at the first internal table and do a select statement in the loop.



Loop at itab.

* Do Select here and whatever else you
* need to do with the data.

endloop.


Regards,

Rich Heilman

Read only

andreas_mann3
Active Contributor
0 Likes
565

Hi,

try :

Loop at itab.

select (single) a1 a2 .. from dbtab

where key1 = itab-f1

and key2 = itab-f2

..

endloop.

Andreas

Read only

Vinod_Chandran
Active Contributor
0 Likes
565

Hi Dilip,

Do you have a performance issue when using For all entries? Please keep in mind that you must check whether the internal table contains some entries. If it is not, then it will select all the records from the table.

For example.

IF NOT ITAB[] IS INITIAL.

SELECT....FROM DBTAB

FOR ALL ENTRIES IN ITAB

WHERE....

ENDIF.

Read only

Former Member
0 Likes
565

Hi, the most scenario for me to use 'For all entrie' is as following:

If several table combine in a join select, maybe it will be poor on performance. So we need to split the join select into several single select. Then after first select, we can prepare the result in a internal table, and use it in another select as 'For all entries in [itab]'.

E.G. as following:

  • original:

select *

into ....

from mseg

inner join in mkpf .....

where mkpfMBLNR = msegMBLNR.

  • it is slow, so we change it

select MBLNR

into table itab

from mkpf.

select *

into ....

from mseg

for all entries in itab

where MBLNR = itab~MBLNR.

Another fact is that the where use 'For all entries in', if the itab is very big, the whole select statement will be compiled and explained to be many pieces of select statements, and sent to DB layer.

So if the 'For all entries in' itab is too large, the select will be slow too.

Hope it will be helpful.

Thanks a lot

Read only

0 Likes
565

Hi ,

Follow the following steps before using FOR ALL ENTRIES -

1) Check internal table that it is not empty .

2) If it have entries then SORT the table .

3) Delete duplicate entries from the table .

4) Use any key field in WHERE clouse.

it may help you.

Regards

NK

Message was edited by: Nandkishor Heda