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

select statement

Former Member
0 Likes
760

hai friends,

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

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

8 REPLIES 8
Read only

Former Member
0 Likes
731

hi,

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

Read only

Former Member
0 Likes
731

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

Read only

Former Member
0 Likes
731

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

Read only

Former Member
0 Likes
731

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

Read only

Former Member
0 Likes
731

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

Read only

Former Member
0 Likes
731

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

Read only

Former Member
0 Likes
731

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

Read only

Former Member
0 Likes
731

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