09-21-2010 5:58 AM
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.
09-21-2010 6:12 AM
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.
09-21-2010 6:12 AM
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.
09-21-2010 8:47 AM
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
09-21-2010 2:00 PM
Moderator message - Please see before posting - post locked Rob