‎2006 Sep 15 6:35 PM
Hi All,
The following code takes a lot of time to execute. Can anyone suggest to fine tune the following inner join statement.
SELECT aebeln aebelp atxz01 amatnr a~werks
algort amenge ameins anetpr a~peinh
awebaz ainsmk apstyp aknttp a~labnr
akonnr aktpnr aevers akunnr a~adrnr
arevlv aemlif aadrn2 amtart aelikz aretpo
blifnr bekgrp bwaers bbedat b~inco1
binco2 cetenr ceindt cslfdt c~menge
cwemng dbanfn d~bnfpo
INTO TABLE t_po
FROM ekko AS b
INNER JOIN ekpo AS a
ON aebeln EQ bebeln
INNER JOIN eket AS c
ON cebeln EQ aebeln
AND cebelp EQ aebelp
LEFT OUTER JOIN eban AS d
ON aebeln EQ debeln
AND aebelp EQ debelp
WHERE b~ebeln IN s_ebeln "Purchasing Document
AND b~bsart IN s_bsart "Document Type
AND b~loekz EQ space "Deletion Indicator, Header
AND b~lifnr IN s_lifnr "Vendor Number
AND b~ekorg IN s_ekorg "Purchasing Organization
AND b~ekgrp IN s_ekgrp "Purchasing Group
AND b~bedat IN s_bedat "Document Date
AND b~bukrs IN s_bukrs
AND a~elikz = space "delivery not complete
AND a~loekz EQ space "Deletion Indicator, Line
AND a~txz01 IN r_txz01 "Short Text
AND a~matnr IN s_matnr "Material Number
AND a~werks IN s_werks "Plant
AND a~lgort IN s_lgort "Storage Location
AND a~matkl IN s_matkl "Material Group
AND a~idnlf IN s_idnlf "Vendor's Material Number
AND a~pstyp IN r_pstyp "Item Category
AND a~knttp IN s_knttp "Account Assign. Category
AND a~bstae IN s_bstae "Confirmation Control Key
AND c~eindt IN s_eindt. "Item Delivery Date
Regards
Brain
‎2006 Sep 15 7:23 PM
‎2006 Sep 15 7:23 PM
‎2006 Sep 15 7:48 PM
Also, your last join:
LEFT OUTER JOIN eban AS d
ON a~ebeln EQ d~ebeln
AND a~ebelp EQ d~ebelp
doesn't use an index. Remove this and see if it speeds things up. If it does, see if there's another way to get this data.
Rob
‎2006 Sep 15 8:37 PM
To follow up on Rob's suggestion, BANFN and BNFPO are on EKPO.