Skip to Content
0
Former Member
Sep 20, 2007 at 11:16 AM

Performance tuning of select with inner join

481 Views

Hi experts,

I need to improve the performanve in these two big selects, could you give me some tips, please?Thanks!

SELECT AWBELN BPOSNR ARFBSK AWFDAT ALIFRE AKNUMV

BZZ_TKNUM BKOWRR BZZ_VSART BZZ_DTABF

CTKNUM CVSART C~TDLNR

CDTABF CSHTYP C~SDABW

DTPNUM DVBELN

EERDAT EVSTEL EKUNNR EANZPK EBTGEW EGEWEI

E~LFDAT

INTO CORRESPONDING FIELDS OF TABLE GT_AGENCY

FROM WBRK AS A

INNER JOIN WBRP AS B

ON AWBELN = BWBELN AND

B~KOWRR EQ ''

INNER JOIN VTTK AS C

ON BZZ_TKNUM = CTKNUM

INNER JOIN VTTP AS D

ON CTKNUM = DTKNUM

INNER JOIN LIKP AS E

ON DVBELN = EVBELN

WHERE A~WBELN IN SO_WBELN AND

A~RFBSK IN SO_RFBSK AND

A~WFDAT IN SO_WFDAT AND

A~LIFRE IN SO_TDLNR AND

B~ZZ_VSART IN SO_VSART AND

B~ZZ_DTABF IN SO_DTABF AND

C~VSART IN SO_VSART AND

D~TKNUM IN SO_REBEL AND

D~VBELN IN SO_VBELN AND

E~ERDAT IN SO_ERDAT AND

E~VSTEL IN SO_VSTEL AND

E~KUNNR IN SO_KUNNR.

SORT GT_AGENCY BY TDLNR VSTEL TKNUM TPNUM VBELN.

DELETE ADJACENT DUPLICATES FROM GT_AGENCY

COMPARING TDLNR VSTEL TKNUM TPNUM VBELN.

IF NOT GT_AGENCY[] IS INITIAL.

SELECT VFKPTDLNR VFKPFKNUM VFKPFKPOS VFKPKNUMV VFSIKPOSN VFKPREBEL VFSIVBELN vfsivbtyp

INTO corresponding fields of TABLE GT_SHIPCOST

FROM VFKP

JOIN VFSI ON VFSIKNUMV = VFKPKNUMV

WHERE VFKP~TDLNR IN SO_TDLNR

AND VFKP~FKNUM IN SO_FKNUM

AND VFKP~FKPOS IN SO_FKPOS

AND VFKP~STBER IN SO_STBER

AND VFKP~FKPTY IN SO_FKPTY

AND ( VFSI~VBTYP = 'J'(S01) OR

VFSI~VBTYP = 'T'(S03) or

vfsi~vbtyp = 'a' ).

ENDIF.

Thanks a lot!

Patricia