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

Making select statement efficient

Former Member
0 Likes
723

Can any one suggest how to make this below statement efficient? It is taking quite a long time to run, wht could be the reasons.

SELECT pbimbedae pbimversb pbimpbdnr pbimmatnr pbim~werks

pbedpdatu pbedplnmg pbed~meins

pbed~aenam

FROM pbim

INNER JOIN pbed ON pbedbdzei = pbimbdzei

INTO TABLE I_IDEMAND

WHERE pbim~werks IN wa_plantsel

AND EXISTS ( SELECT matnr FROM mara

WHERE matnr = pbim~matnr

AND lvorm = '' )

AND EXISTS ( SELECT matnr FROM marc

WHERE marcmatnr = pbimmatnr

AND marcwerks = pbimwerks

AND marc~lvorm = '' )

AND pbim~vervs = 'X'

AND pbed~plnmg > 0 .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
597

Hi,

1. First of all the sequence of fields in select query for PBIM & PBED table should be same as database table.

2. First select the data from mara & marc the fetch data from pbim.

This should solve ur performnace problem .

Regards

Kapil

3 REPLIES 3
Read only

Former Member
0 Likes
597

first break the Join ,

first get MATNR from MARA+MARC , then go for Planning data.

Regards

Prabhu

Read only

Former Member
0 Likes
598

Hi,

1. First of all the sequence of fields in select query for PBIM & PBED table should be same as database table.

2. First select the data from mara & marc the fetch data from pbim.

This should solve ur performnace problem .

Regards

Kapil

Read only

Former Member
0 Likes
597

hi

good

use CORRESPONDIG FIELDS OF TABLE statement and see the difference.

thanks

mrutyun