Archived discussions are read-only. Learn more about SAP Q&A

Need help for performance tuning select statement

Hello experts,

can anybody check the coding how to speed up the performance ?

The bottleneck seems to ne in the selection from cdpos and cdhdr,

but this are large tables.

SELECT * FROM cdhdr WHERE objectclas = 'DEBI' AND tcode = 'VD02' AND udate = sy-datum

OR objectclas = 'DEBI' AND tcode = 'XD02' AND udate = sy-datum.

IF sy-subrc = 0.

changenr = cdhdr-changenr.

objectid = cdhdr-objectid.

SELECT SINGLE * FROM cdpos INTO wa_cdpos WHERE changenr = changenr AND fname = 'AUFSD'

OR changenr = changenr AND fname = 'LIFSD'

OR changenr = changenr AND fname = 'FAKSD'.

IF wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = '01' OR

wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'VK' OR

wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = '02' OR

wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = '03' OR

wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'VK' OR

wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'SL'.

APPEND wa_cdpos TO it_cdpos.

ENDIF.

IF sy-subrc = 0.

objectid = cdpos-objectid.

fname = cdpos-fname.

chngind = cdpos-chngind.

value_new = cdpos-value_new.

value_old = cdpos-value_old.

kundennummer = cdpos-objectid.

  • PERFORM email.

ENDIF.

ENDIF.

ENDSELECT.

BR Gerd

  • SAP Employee
replied

if there are standard interfaces then try to use them.

You should always try to write a complete WHERE-clause, and of course try to be simple

IF wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = '01' OR
wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'VK' OR
wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = '02' OR
wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = '03' OR
wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'VK' OR
wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'SL'.

is the same as

AND cdpos-chngind = 'U' 
AND cdpos-value_new  IN ( '01' , '02', '03', 'VK', 'SL' )

Note, that lines 2 and 5 are identical !!

wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'VK' OR

wa_cdpos-chngind = 'U' AND wa_cdpos-value_new = 'VK' OR

Try to convert the SELECT - SELECT SINGLE - ENDSELECT into a Join!

Ich h├Ątte auch eine Literaturempfehlung in Deutsch:

http://www.dpunkt.de/buecher/3096.html

Siegfried

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question