10-14-2008 2:17 PM
Hi,
Is it acceptable to use SELECT SINGLE statement within a LOOP? Or is it very bad for the performace?
Is there any alternative (better way) for this?
I can't use READ because don't have any fields to compare in the WITH KEY section..
Thanks,
Mohit
10-14-2008 2:21 PM
Hi
Its very bad for performance as every time it will Read database.
If you dont have any vale to compae that SELECT SINGLE also gives you same value every time otherwise you can use FOR ALL ENTRIES claues.
Regards
Aditya
10-14-2008 2:26 PM
If you have the keys used in the SELECT in the table looped, use a FOR ALL ENTRIES IN itab, then in the loop use a READ TABLE.
If not, perform a first loop, collect the needed keys in a second itab, at the end of the first loop perform the SELECT FOR ALL ENTRIES, then perform a second loop with the READ TABLE.
LOOP/SELECT SINGLE/ENDLOOP is only advisable if you are sure that only a few records will be read, like in a screen dynpro without ALV or views.
Regards