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: 

Normalise the select statement

rohit_kaikala
Participant
0 Kudos
94

Hi folks,

I have a select statement which is taking more than 10min to execute.

SELECT aebeln abedat

aihrez areswk

a~unsez

bebelp bmatnr

bwerks blgort

bmatkl bmenge

FROM ekko AS a INNER JOIN ekpo AS b

ON aebeln EQ bebeln

INTO CORRESPONDING FIELDS OF TABLE sto_tab

WHERE a~ebeln IN s_ebeln

AND a~bstyp EQ 'F'

AND a~bsart IN ('ZUB1' ,'ZUB2')

AND a~loekz EQ ' '

AND a~ekorg EQ '6000'

AND a~reswk EQ p_reswk

AND b~loekz EQ ' '

AND b~matnr IN s_matnr

AND b~werks IN s_werks

AND b~lgort EQ p_lgort

AND b~elikz NE 'X'

AND b~bstyp EQ 'F'.

Please give me some suggestions to get more faster.

Regards,

Rohith.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
60

Hi rohit kaikala,

Not sure whether it will increase the performance but try once :

Add LOEKZ,EKORG,BSTYP in your internal table and using DELETE command delete them. Just try if it can increase the performance.


SELECT a~ebeln a~bedat
a~ihrez a~reswk
a~unsez
b~ebelp b~matnr
b~werks b~lgort
b~matkl b~menge
FROM ekko AS a INNER JOIN ekpo AS b
ON a~ebeln EQ b~ebeln
INTO CORRESPONDING FIELDS OF TABLE sto_tab
WHERE a~ebeln IN s_ebeln
AND a~bsart IN ('ZUB1' ,'ZUB2')
AND a~reswk EQ p_reswk
AND b~matnr IN s_matnr
AND b~werks IN s_werks
AND b~lgort EQ p_lgort
AND b~elikz NE 'X'.
"Here you DELETE itab as required like 
DELETE STO_TAB WHERE LOEKZ IS NOT INITIAL.
DELETE STO_TAB WHERE BSTYP NE 'F'.
DELETE STO_TAB WHERE EKORG NE '6000'.

Thanks & Regards,

Rock.

3 REPLIES 3

Former Member
0 Kudos
61

Hi rohit kaikala,

Not sure whether it will increase the performance but try once :

Add LOEKZ,EKORG,BSTYP in your internal table and using DELETE command delete them. Just try if it can increase the performance.


SELECT a~ebeln a~bedat
a~ihrez a~reswk
a~unsez
b~ebelp b~matnr
b~werks b~lgort
b~matkl b~menge
FROM ekko AS a INNER JOIN ekpo AS b
ON a~ebeln EQ b~ebeln
INTO CORRESPONDING FIELDS OF TABLE sto_tab
WHERE a~ebeln IN s_ebeln
AND a~bsart IN ('ZUB1' ,'ZUB2')
AND a~reswk EQ p_reswk
AND b~matnr IN s_matnr
AND b~werks IN s_werks
AND b~lgort EQ p_lgort
AND b~elikz NE 'X'.
"Here you DELETE itab as required like 
DELETE STO_TAB WHERE LOEKZ IS NOT INITIAL.
DELETE STO_TAB WHERE BSTYP NE 'F'.
DELETE STO_TAB WHERE EKORG NE '6000'.

Thanks & Regards,

Rock.

Former Member
0 Kudos
60

Hi,

Remove the into corresponding fields statement and also use fields in same sequence as in table.

try to use the primary index in where condition.

Regards

Shiva

Former Member
0 Kudos
60

Moderator message - Please see before posting - post locked Rob