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 query modification

Former Member
0 Likes
686

Hi,

This below mentioned select statement taking more time to execute so i am planning to devide into parts. Please do let me know if any better suggestions on its division.

SELECT ekko~ebeln

ekko~lifnr

ekko~bukrs

ekbe~ebelp

ekbe~budat

ekbe~belnr

ekbe~gjahr

ekbe~wrbtr

ekbe~shkzg

ekbe~xblnr

INTO TABLE it_poir_dtl

FROM ekbe

INNER JOIN ekko ON

ekbeebeln = ekkoebeln

FOR ALL entries IN it_bkpf

WHERE ekbe~vgabe = '1'

AND ekko~bukrs = it_bkpf-bukrs

AND ekbe~belnr = it_bkpf-awkey(10)

AND ekbe~gjahr = it_bkpf-gjahr

AND lifnr BETWEEN '0000100000' and '0000199999'.

Earliest reply would help me a lot.

Thanks,

Devasing

5 REPLIES 5
Read only

Former Member
0 Likes
653

Hi,

Avoid the use of join and split the query into 3 using the for all enteries this will help.

bkpf

ekko

ekbe

regards,

Midhun Abraham

Read only

Former Member
0 Likes
653

SELECT ebeln

lifnr

bukrs from ekko into table t_ekko

where lifnr BETWEEN '0000100000' and '0000199999'.

if t_ekko[] is not initial.

SELECT ebelp

budat

belnr

gjahr

wrbtr

shkzg

xblnr FROM ekbe into table t_ekbe

for all entries in table t_ekko

where ebeln = t_ekko-ebeln

endif.

Read only

viquar_iqbal
Active Contributor
0 Likes
653

Hi

divide your query into 2 parts.

In first select use FOR ALL ENTRIES into itab.

SELECT ekko~ebeln

ekko~lifnr

ekko~bukrs

ekbe~ebelp

ekbe~budat

ekbe~belnr

ekbe~gjahr

ekbe~wrbtr

ekbe~shkzg

ekbe~xblnr

INTO TABLE it_poir_dtl

FROM ekbe

INNER JOIN ekko ON

ekbeebeln = ekkoebeln

and lifnr BETWEEN '0000100000' and '0000199999'.

Loop at it_bkpf into fs_bkpf.

read table it_poir_dtl into fs_poir.

if fs_poir-bukrs NE fs_bkpf-bukrs and

fs_poir-belnr NE fs_bkpf-awkey ...

then delete the row else continue.

endloop.

Hope this helps.

Viquar Iqbal

Read only

Former Member
0 Likes
653

Hi you need to use Key fields in the where clause.Then performence will increase and also try to avoind between in the select query.

Thanks.

Read only

Former Member
0 Likes
653

hi,

kindly use FOR ALL ENTRIES instead of using join in your select query.

it will definately solve your problem

regards

rahul