‎2008 Dec 12 2:14 PM
Hi,
Can we do furthur performance tuning on the below code. Thanks.
Best Regards
Suresh
form check_fac.
data: begin of it_eslh_knumv occurs 0,
packno like eslh-packno,
knumv like eslh-knumv,
end of it_eslh_knumv,
begin of it_ses_konv occurs 0,
knumv like konv-knumv,
kschl like konv-kschl,
kposn like konv-kposn,
kwert like konv-kwert,
kpein like konv-kpein,
kmein like konv-kmein,
kbetr like konv-kbetr,
end of it_ses_konv,
l_idx like sy-tabix,
l_kposn like konv-kposn.
sort: it_essr by ebeln ebelp.
loop at it_essr into wa_essr.
wa_s994-mandt = sy-mandt.
wa_s994-zzebeln_02 = wa_essr-ebeln.
wa_s994-zzebelp_03 = wa_essr-ebelp.
(some more assignments here)
loop at it_ses_package into wa_ses_package
where packno_h = wa_essr-packno.
* ESLH data
wa_s994-zzpackno2 = wa_ses_package-packno_h.
wa_s994-zzdel1 = wa_ses_package-packno_h.
wa_s994-zzfpackno = wa_ses_package-fpackno.
wa_s994-zzhpackno = wa_ses_package-hpackno.
(some more assignments here)
loop at it_esll_plus2 into wa_esll_plus2
where packno = wa_ses_package-sub_packno.
wa_s994-zzintrow2 = wa_esll_plus2-introw.
wa_s994-zzsrvpos = wa_esll_plus2-srvpos.
wa_s994-zzmenge2 = wa_esll_plus2-menge.
wa_s994-zzktext11 = wa_esll_plus2-ktext1.
append wa_s994 to it_s994.
endloop.
endloop.
endloop.
* Get all the condition no. from ESLH for the sub package numbers
select packno knumv from eslh into table it_eslh_knumv
for all entries in it_s994
where packno = it_s994-zzpackn_01.
* Get all the condition records from KONV
select knumv kschl kposn kwert kpein kmein kbetr
from konv
into corresponding fields of table it_ses_konv
for all entries in it_eslh_knumv
where ( kschl = 'PRS' or kschl = 'Z001'
or kschl = 'Z002' or kschl = 'Z003' )
and kappl = 'MS'
and knumv = it_eslh_knumv-knumv.
sort it_eslh_knumv by packno knumv.
sort it_s994 by zzpackn_01 zzintrow2.
sort it_ses_konv by knumv kposn.
if not it_ses_konv[] is initial.
loop at it_s994 into wa_s994.
l_idx = sy-tabix.
read table it_eslh_knumv with key packno = wa_s994-zzpackn_01 binary search.
if sy-subrc = 0.
clear l_kposn.
l_kposn = wa_s994-zzintrow2.
read table it_ses_konv with key knumv = it_eslh_knumv-knumv kposn = l_kposn binary search.
if sy-subrc = 0.
loop at it_ses_konv where knumv = it_eslh_knumv-knumv and kposn = l_kposn.
if it_ses_konv-kschl = 'PRS'.
wa_s994-zzkwert_p = it_ses_konv-kwert.
wa_s994-zzkpein_p = it_ses_konv-kpein.
wa_s994-zzkmein_p = it_ses_konv-kmein.
wa_s994-zzkbetr_p = it_ses_konv-kbetr.
endif.
if it_ses_konv-kschl = 'Z001'.
wa_s994-zzkwert_1 = it_ses_konv-kwert.
wa_s994-zzkpein_1 = it_ses_konv-kpein.
wa_s994-zzkmein_1 = it_ses_konv-kmein.
wa_s994-zzkbetr_1 = it_ses_konv-kbetr.
endif.
if it_ses_konv-kschl = 'Z002'.
wa_s994-zzkwert_2 = it_ses_konv-kwert.
wa_s994-zzkpein_2 = it_ses_konv-kpein.
wa_s994-zzkmein_2 = it_ses_konv-kmein.
wa_s994-zzkbetr_2 = it_ses_konv-kbetr.
endif.
if it_ses_konv-kschl = 'Z003'.
wa_s994-zzkwert_3 = it_ses_konv-kwert.
wa_s994-zzkpein_3 = it_ses_konv-kpein.
wa_s994-zzkmein_3 = it_ses_konv-kmein.
wa_s994-zzkbetr_3 = it_ses_konv-kbetr.
endif.
at end of kposn.
modify it_s994 index l_idx
from wa_s994
transporting zzkwert_p zzkpein_p zzkmein_p zzkbetr_p
zzkwert_1 zzkpein_1 zzkmein_1 zzkbetr_1
zzkwert_2 zzkpein_2 zzkmein_2 zzkbetr_2
zzkwert_3 zzkpein_3 zzkmein_3 zzkbetr_3.
endat.
endloop.
endif.
endif.
endloop.
endif.
endform. " check_facEdited by: Julius Bussche on Dec 12, 2008 4:19 PM
‎2008 Dec 12 2:29 PM
‎2008 Dec 15 7:01 AM
Hi,
1. Instead of using 'occurs 0' use 'types' in data declaration.
2. try to used field-symbol instead of work area or header line.
3. try to use Read statemene rather than nested loop
4. try to avoid move corresponding in select statement.
5. before using the 'for all entries' you should be check the table is initial or not.
6.in where clause we may write this where kschl in ( 'PRS' , 'Z001', 'Z002', 'Z003' )
i hope this is useful for u .
Regards:
Mahesh
‎2008 Dec 15 1:39 PM
‎2008 Dec 15 2:28 PM
Hi,
Just go through your code & use for all entries if used joins.
Use all key fields when using for all entries.
Use binary search when reading...
Thanks,
Krishna...
‎2008 Dec 15 2:46 PM
Hi,
please ask yourself these questions:
why there is still a join syntax in OPEN SQL if you only need to speed up the performance with FAE?
why there are SAP Notes about FAE pitfalls and KNOWN performance issues with them?
Your apporoach is: I will turn all my problems into nails so I only have to use my hammer (wich is the only tool I need ever).
Sorry, but in reality you need a set of tools (means:Joins are not always evil, FAE are not always good)
bye
yk
‎2009 Jan 30 6:09 AM