08-09-2007 2:30 PM
hai friends,
Can we use SELECT statement in LOOP ... ENDLOOP.
If yes, what about the performance, can it be same.
08-09-2007 2:33 PM
hi,
we shdn't use SELECT stmt within the loop it will decreases the performance.
08-09-2007 2:34 PM
Hi,
Dont use the SELECT statement with in the loop it will effect the performance.
It will be better to select the data before using the loop
rgds
harris
08-09-2007 2:34 PM
You can use, but performance wise it is not preferable.....
You are hitting the database table 'n' number of times if you call it inside a loop. where 'n' is the number of records,
So, write SELECT outside a loop, using FOR ALL ENTRIES.
Regards,
Pavan
08-09-2007 2:35 PM
Hi,
You can use the Select statment in the LOOP and ENDLOOP. But it is performance issue, so better write the select out of the LOOP and use the READ statment with in the LOOP.
Regards
Sudheer
08-09-2007 2:35 PM
Sample code........
SELECT EBELN " Purchasing Document Number
ERNAM " Name of Person who Created
" the Object
LIFNR " Vendor's account number
EKGRP " Purchasing group
BEDAT " Purchasing Document Date
FROM EKKO
INTO T_EBELN
WHERE EBELN IN S_EBELN
AND BEDAT IN S_BEDAT.
SELECT OBJECTCLAS " Object Class
OBJECTID " Object value
CHANGENR " Document change number
USERNAME " User name
UDATE " Creation date
FROM CDHDR
INTO TABLE T_CDHDR
FOR ALL ENTRIES IN T_EBELN
WHERE OBJECTID EQ T_EBELN-EBELN
AND UDATE IN S_UDATE
AND TCODE IN ('ME21N','ME22N','ME23N').
Regards,
Pavan
08-09-2007 2:37 PM
Hi Jay
u can use no syntax error but it is performance issue try to avoid this one
reward points to all helpful answers
kiran.M
08-09-2007 2:59 PM
its advisable not to use select statement inside he loop , definitely, it ll reduce the performance.
08-09-2007 3:07 PM
its advisable not to use select statement inside he loop , definitely, it ll reduce the performance.