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: 

select statement

Former Member
0 Kudos

hai friends,

Can we use SELECT statement in LOOP ... ENDLOOP.

If yes, what about the performance, can it be same.

8 REPLIES 8

Former Member
0 Kudos

hi,

we shdn't use SELECT stmt within the loop it will decreases the performance.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

its advisable not to use select statement inside he loop , definitely, it ll reduce the performance.

Former Member
0 Kudos

its advisable not to use select statement inside he loop , definitely, it ll reduce the performance.