Skip to Content
0
Former Member
Oct 19, 2006 at 03:51 PM

Performance issue

28 Views

Hi,

I have performance issue on this report, Please let me know if the code can be written in a better way, I am following the indices and order everything,

Code:

select bukrs hkont augdt augbl gjahr belnr buzei

budat bldat xblnr blart shkzg dmbtr wrbtr

sgtxt aufnr kostl dmbe2 prctr zztitle

zzterr from bsis into table i_data

WHERE hkont IN so_hkont

AND bukrs IN so_bukrs

AND augdt IN so_augdt

AND gjahr IN so_gjahr

AND belnr IN so_belnr

AND budat IN so_budat

AND bldat IN so_bldat

AND xblnr IN so_xblnr

AND blart IN so_blart

AND aufnr IN so_aufnr

AND kostl IN so_kostl

AND prctr IN so_prctr

AND zztitle IN so_title

AND zzterr IN so_terr.

if not i_data[] is initial.

move i_data[] to t_data[].

loop at t_data.

select single cpudt bvorg waers bstat hwaer hwae2

from bkpf into corresponding fields of t_data

where bukrs = t_data-bukrs and

belnr = t_data-belnr and

gjahr = t_data-gjahr.

modify t_data index sy-tabix.

endloop.

if not so_cpudt is initial.

if so_cpudt-high is initial.

move so_cpudt-low to so_cpudt-high.

endif.

so_cpudt-sign = 'E'.

modify so_cpudt index 1.

delete t_data where cpudt in so_cpudt.

endif.

if not so_bvorg is initial.

if so_bvorg-high is initial.

move so_bvorg-low to so_bvorg-high.

endif.

so_bvorg-sign = 'E'.

modify so_bvorg index 1.

delete t_data where bvorg in so_bvorg.

endif.

refresh i_data.

clear i_data.

clear t_data.

free i_data.

This was the earlier code, code had inner join,

I changed to above manner

Older version

Code:

SELECT bsisbukrs bsisbelnr bsisgjahr bsisblart bsis~bldat

bsisbudat bsisxblnr bkpfbvorg bkpfbstat bkpf~waers

bkpfhwaer bkpfhwae2 bsisbuzei bsisaugdt bsis~augbl

bsisshkzg bsisdmbtr bsiswrbtr bsisdmbe2 bsis~sgtxt

bsiskostl bsisaufnr bsishkont bsisprctr bkpf~cpudt

bsiszztitle bsiszzterr

FROM bsis

JOIN bkpf

ON bkpfbukrs EQ bsisbukrs

AND bkpfbelnr EQ bsisbelnr

AND bkpfgjahr EQ bsisgjahr

INTO CORRESPONDING FIELDS OF t_data

WHERE bsis~bukrs IN so_bukrs

AND bsis~hkont IN so_hkont

AND bsis~budat IN so_budat

AND bsis~augdt IN so_augdt

AND bsis~gjahr IN so_gjahr

AND bsis~belnr IN so_belnr

AND bsis~blart IN so_blart

AND bsis~xblnr IN so_xblnr

AND bsis~bldat IN so_bldat

AND bsis~zztitle IN so_title

AND bsis~zzterr IN so_terr

AND bsis~kostl IN so_kostl

AND bsis~prctr IN so_prctr

AND bsis~aufnr IN so_aufnr

AND bkpf~cpudt IN so_cpudt "-( BKPF

AND bkpf~bvorg IN so_bvorg. "- (BKPF)

For some selection criteria, the older version is executing fast than new version, but most of the times the new version of code which I changed is executed fast.

please let me know if any changes I need to make in the new version of code to make it better so that for any selection criteria it is executed first.

Thanks

Thanks