Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Performance Tuning

Former Member
0 Likes
623

Hi All,

I have one RFC 'ZBW_XXXXX' . Maximum performance needed from my RFC. Currently it is taking some micro seconds. i want to reduce as possible we can do.

Iam pasting code...

In the Below statmemt i have remove aggregate functions

and i done my best in ABAP Coding for this part.

Functionality wise that logic is working correct . it is done

with help at end of control statement and use SUM keyword

inside the internal table loop.

But still performance wise it is taking more time than

the Current select stamt with AggregateFunctions.

Also one point in given select query , group by Clause

fields like kf_key, TEXT1, TEXT2, TEXT3 ,TEXT4, are not key fields of Ztable.

Apart from select query,any other also Performance can

be Improved.

CODE AS FOLLOWS:

select subreg country site plant kf_key TEXT1 TEXT2 TEXT3 TEXT4 sum( period1 ) as period1 sum( period2 ) as period2

sum( period3 ) as period3 sum( period4 ) as period4

sum( period5 ) as period5 sum( period6 ) as period6

sum( period7 ) as period7 sum( period8 ) as period8

sum( period9 ) as period9 sum( period10 ) as period10

sum( period11 ) as period11 sum( period12 ) as period12

sum( period13 ) as period13 sum( period14 ) as period14

sum( period15 ) as period15 sum( period16 ) as period16

sum( period17 ) as period17 sum( period18 ) as period18

sum( period19 ) as period19 sum( period20 ) as period20

sum( period21 ) as period21 sum( period22 ) as period22

sum( period23 ) as period23 sum( period24 ) as period24

from ZBW_LPAD_ANALYST

into corresponding fields of table xit_analyst

where subreg in S_SUBREG

and country in S_COUNTRY

and site in S_SITE

and plant in S_PLANT

and sph in S_SPH

and spm in S_SPM

and spl in S_SPL

and supgbu in S_SUPGBU

and gbu in S_GBU

and procmt in S_PROCMT

and apvendor in S_VENDOR

group by subreg country site plant kf_key TEXT1 TEXT2 TEXT3 TEXT4.

loop at xit_analyst into WA_ANALYST.

clear: WA_CY, WA_LY, wa_from, wa_from1.

wa_from1 = wa_from_c.

wa_from = wa_from_l.

do wa_to times.

  • Get current year period values

if wa_from1 >= 13.

move: wa_from1 to period_from.

concatenate 'PERIOD' period_from into wa_period.

condense wa_period.

assign wa_period to <wa_fs>.

assign component <wa_fs> of structure wa_analyst to <wa_fs1>.

wa_cy = wa_cy + <wa_fs1>.

endif.

  • Get Last year period values

if wa_from <= 12.

move: wa_from to period_from.

concatenate 'PERIOD' period_from into wa_period.

condense wa_period.

assign wa_period to <wa_fs>.

assign component <wa_fs> of structure wa_analyst to <wa_fs1>.

wa_ly = wa_ly + <wa_fs1>.

endif.

wa_from = wa_from + 1.

wa_from1 = wa_from1 + 1.

enddo.

if wa_cy eq 0 and wa_ly eq 0.

clear: WA_ANALYST, wa_cy, wa_ly, WA_ANLST.

continue.

endif.

read table IT_ANLST into WA_ANLST with key

ZP_SUBREG = WA_ANALYST-SUBREG

GPU_0COUNTRY = WA_ANALYST-COUNTRY

  • GPUBWSITE = WA_ANALYST-SITE

GPU_0PLANT = WA_ANALYST-PLANT.

if SY-SUBRC eq 0.

case WA_ANALYST-KF_KEY.

when '49FBA3CTDNHMK46IHJRCXO7W5'.

WA_ANLST-GPUGLBCUR_CY = WA_ANLST-GPUGLBCUR_CY + WA_CY.

WA_ANLST-GPUGLBCUR_LY = WA_ANLST-GPUGLBCUR_LY + WA_LY.

when '49FBA3KHWM3C2QPYNDTP7Q6LX'.

WA_ANLST-GPUINVHDR_CY = WA_ANLST-GPUINVHDR_CY + WA_CY.

WA_ANLST-GPUINVHDR_LY = WA_ANLST-GPUINVHDR_LY + WA_LY.

when '49FBA3S6FKP1LD9ET7W1HS5BP'.

WA_ANLST-GPUINLITM_CY = WA_ANLST-GPUINLITM_CY + WA_CY.

WA_ANLST-GPUINLITM_LY = WA_ANLST-GPUINLITM_LY + WA_LY.

when '49FBA3ZUYJAR3ZSUZ1YDRU41H'.

WA_ANLST-GPUINWOPO_CY = WA_ANLST-GPUINWOPO_CY + WA_CY.

WA_ANLST-GPUINWOPO_LY = WA_ANLST-GPUINWOPO_LY + WA_LY.

when '49FBA47JHHWGMMCB4W0Q1W2R9'.

WA_ANLST-GPUTOT_PO_CY = WA_ANLST-GPUTOT_PO_CY + WA_CY.

WA_ANLST-GPUTOT_PO_LY = WA_ANLST-GPUTOT_PO_LY + WA_LY.

when '49FBA4F80GI658VRAQ32BY1H1'.

WA_ANLST-GPUN_LNIT_CY = WA_ANLST-GPUN_LNIT_CY + WA_CY.

WA_ANLST-GPUN_LNIT_LY = WA_ANLST-GPUN_LNIT_LY + WA_LY.

when '49FBA4UL2DPL6HYNME7QW1YWL'. " FI Spend

WA_ANLST-GPUFISPND_CY = WA_ANLST-GPUFISPND_CY + WA_CY.

WA_ANLST-GPUFISPND_LY = WA_ANLST-GPUFISPND_LY + WA_LY.

when '49FBA5HMN9IPQDL03WERQ7V1X'. " Compliant spend

WA_ANLST-GPUPSLCMS_CY = WA_ANLST-GPUPSLCMS_CY + WA_CY.

WA_ANLST-GPUPSLCMS_LY = WA_ANLST-GPUPSLCMS_LY + WA_LY.

when '49FBA6RPT14YU4TP2WSTEJNCL'. " Compliant #

WA_ANLST-GPUPSLCOM_CY = WA_ANLST-GPUPSLCOM_CY + WA_CY.

WA_ANLST-GPUPSLCOM_LY = WA_ANLST-GPUPSLCOM_LY + WA_LY.

when '49FBA81SYSR7XW2E1X6V2VFN9'. " MRP and Catalog PO lines

WA_ANLST-GPUPSLMRP_CY = WA_ANLST-GPUPSLMRP_CY + WA_CY.

WA_ANLST-GPUPSLMRP_LY = WA_ANLST-GPUPSLMRP_LY + WA_LY.

when '49FBA772UYCDVDWLEKXHYNKS5'. " Procurement method compliant #

WA_ANLST-GPUMTCOMP_CY = WA_ANLST-GPUMTCOMP_CY + WA_CY.

WA_ANLST-GPUMTCOMP_LY = WA_ANLST-GPUMTCOMP_LY + WA_LY.

when '49FBA7MFWVJSWMZHQ926IRI7P'. " Sourcing compliant #

WA_ANLST-GPUSRCOMP_CY = WA_ANLST-GPUSRCOMP_CY + WA_CY.

WA_ANLST-GPUSRCOMP_LY = WA_ANLST-GPUSRCOMP_LY + WA_LY.

when '49FBA5WZP6Q4RMNWFKJGABSHH'. " Procurement method compliant spend

WA_ANLST-GPUMTCMPS_CY = WA_ANLST-GPUMTCMPS_CY + WA_CY.

WA_ANLST-GPUMTCMPS_LY = WA_ANLST-GPUMTCMPS_LY + WA_LY.

when '49FBA6CCR3XJSVQSR8O4UFPX1'. " Sourcing compliant spend

WA_ANLST-GPUSRCMPS_CY = WA_ANLST-GPUSRCMPS_CY + WA_CY.

WA_ANLST-GPUSRCMPS_LY = WA_ANLST-GPUSRCMPS_LY + WA_LY.

endcase.

  • clear: wa_anlst-gpu_0plant.

modify it_anlst from wa_anlst index sy-tabix.

else.

move: WA_ANALYST-SUBREG to wa_anlst-ZP_SUBREG,

WA_ANALYST-TEXT1 to wa_anlst-text1,

WA_ANALYST-COUNTRY to wa_anlst-GPU_0COUNTRY,

WA_ANALYST-TEXT2 to wa_anlst-text2,

WA_ANALYST-SITE to wa_anlst-GPUBWSITE,

WA_ANALYST-TEXT3 to wa_anlst-text3,

WA_ANALYST-PLANT to wa_anlst-GPU_0PLANT,

WA_ANALYST-TEXT4 to wa_anlst-text4.

case WA_ANALYST-KF_KEY.

when '49FBA3CTDNHMK46IHJRCXO7W5'.

WA_ANLST-GPUGLBCUR_CY = WA_CY.

WA_ANLST-GPUGLBCUR_LY = WA_LY.

when '49FBA3KHWM3C2QPYNDTP7Q6LX'.

WA_ANLST-GPUINVHDR_CY = WA_CY.

WA_ANLST-GPUINVHDR_LY = WA_LY.

when '49FBA3S6FKP1LD9ET7W1HS5BP'.

WA_ANLST-GPUINLITM_CY = WA_CY.

WA_ANLST-GPUINLITM_LY = WA_LY.

when '49FBA3ZUYJAR3ZSUZ1YDRU41H'.

WA_ANLST-GPUINWOPO_CY = WA_CY.

WA_ANLST-GPUINWOPO_LY = WA_LY.

when '49FBA47JHHWGMMCB4W0Q1W2R9'.

WA_ANLST-GPUTOT_PO_CY = WA_CY.

WA_ANLST-GPUTOT_PO_LY = WA_LY.

when '49FBA4F80GI658VRAQ32BY1H1'.

WA_ANLST-GPUN_LNIT_CY = WA_CY.

WA_ANLST-GPUN_LNIT_LY = WA_LY.

when '49FBA4UL2DPL6HYNME7QW1YWL'. " FI Spend

WA_ANLST-GPUFISPND_CY = WA_CY.

WA_ANLST-GPUFISPND_LY = WA_LY.

when '49FBA5HMN9IPQDL03WERQ7V1X'. " Compliant spend

WA_ANLST-GPUPSLCMS_CY = WA_CY.

WA_ANLST-GPUPSLCMS_LY = WA_LY.

when '49FBA6RPT14YU4TP2WSTEJNCL'. " Compliant #

WA_ANLST-GPUPSLCOM_CY = WA_CY.

WA_ANLST-GPUPSLCOM_LY = WA_LY.

when '49FBA81SYSR7XW2E1X6V2VFN9'. " MRP and Catalog PO lines

WA_ANLST-GPUPSLMRP_CY = WA_CY.

WA_ANLST-GPUPSLMRP_LY = WA_LY.

when '49FBA772UYCDVDWLEKXHYNKS5'. " Procurement method compliant #

WA_ANLST-GPUMTCOMP_CY = WA_CY.

WA_ANLST-GPUMTCOMP_LY = WA_LY.

when '49FBA7MFWVJSWMZHQ926IRI7P'. " Sourcing compliant #

WA_ANLST-GPUSRCOMP_CY = WA_CY.

WA_ANLST-GPUSRCOMP_LY = WA_LY.

when '49FBA5WZP6Q4RMNWFKJGABSHH'. " Procurement method compliant spend

WA_ANLST-GPUMTCMPS_CY = WA_CY.

WA_ANLST-GPUMTCMPS_LY = WA_LY.

when '49FBA6CCR3XJSVQSR8O4UFPX1'. " Sourcing compliant spend

WA_ANLST-GPUSRCMPS_CY = WA_CY.

WA_ANLST-GPUSRCMPS_LY = WA_LY.

endcase.

  • clear: wa_anlst-gpu_0plant.

append wa_anlst to it_anlst.

endif.

  • Subregion

read table ew_subreg into wa_nv with key fieldname = wa_anlst-zp_subreg.

if sy-subrc ne 0.

move: wa_anlst-zp_subreg to wa_nv-fieldname,

wa_anlst-text1 to wa_nv-value.

append wa_nv to ew_subreg.

endif.

  • Country

read table ew_country into wa_nv with key fieldname = wa_anlst-gpu_0country.

if sy-subrc ne 0.

move: wa_anlst-gpu_0country to wa_nv-fieldname,

wa_anlst-text2 to wa_nv-value.

append wa_nv to ew_country.

endif.

  • Plant

read table ew_plant into wa_nv with key fieldname = wa_anlst-GPU_0PLANT.

if sy-subrc ne 0.

move: wa_anlst-gpu_0plant to wa_nv-fieldname,

wa_anlst-text4 to wa_nv-value.

append wa_nv to ew_plant.

endif.

  • Site

read table ew_site into wa_nv with key fieldname = wa_anlst-GPUBWSITE.

if sy-subrc ne 0.

move: wa_anlst-GPUBWSITE to wa_nv-fieldname,

wa_anlst-text3 to wa_nv-value.

append wa_nv to ew_site.

endif.

clear: WA_ANALYST, wa_cy, wa_ly, WA_ANLST.

endloop.

and plant in S_PLANT

and sph in S_SPH

and spm in S_SPM

and spl in S_SPL

and supgbu in S_SUPGBU

and gbu in S_GBU

and procmt in S_PROCMT

and apvendor in S_VENDOR

group by subreg country site plant kf_key TEXT1 TEXT2 TEXT3 TEXT4.

Helpful answers wil be rewarded.

BestRegards,

anilkumar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
602

hi sutharapu,

perhaps a view tipps and questions that will get you on your way.

why the ... into corresponding fields of table xit_analyst ...? It could be better if you work with one internal table for the selection result and another for the result of logical operations.

> loop at xit_analyst into WA_ANALYST.

better would be loop at ... assigning <FS_ANALYST>.

Instad of your read table with key you could try READ TABLE ... WITH BINARY SEARCH if it's possible to sort your internal tables in the correct way.

4 REPLIES 4
Read only

Former Member
0 Likes
603

hi sutharapu,

perhaps a view tipps and questions that will get you on your way.

why the ... into corresponding fields of table xit_analyst ...? It could be better if you work with one internal table for the selection result and another for the result of logical operations.

> loop at xit_analyst into WA_ANALYST.

better would be loop at ... assigning <FS_ANALYST>.

Instad of your read table with key you could try READ TABLE ... WITH BINARY SEARCH if it's possible to sort your internal tables in the correct way.

Read only

0 Likes
602

Hi Robert,

I forgot to say one more point here .

Iam using 5 select queries with different search criteria

select query1:

i mean to say GROUP BY clause subrg country site plant kf_key TEXT1 TEXT2 TEXT3 TEXT4.

selectquery2:

I mean to say Group by clause for

sph spm spl kf_key TEXT5 TEXT6 TEXT7.

selectquery3:

GROUP BY clause for

supgbu gbu kf_key TEXT8 TEXT9.

select query4:

Group by clause for

apvendor kf_key TEXT11.

select query 5:

group by clause for

procmt kf_key TEXT10.

All the 5 select queries are same but group by clause will change and also different data(fields) is fetched but same where condition.

Here in Group by clause,non key fields also specified.

All the code i pasted is same for 5 select queries but with

differnt group by clause but SUM to be done for all queries.

Thats why *select into correspondign fields of table is used

Also binary search is not possible in my case,since internal

tables are building dynamically.so i cannt sort itab by fields....

Edited by: sutharapu anilkumar on May 15, 2008 5:20 PM

Read only

0 Likes
602

Hi Anil,

the code that you have written looks pretty much in accordance with the performance considerations.. However I am still confused on your using of 'into corresponding fields of table' . Could you kindly explain it to me.. I am sure this can be removed in some way and that will improve the performance of your code further.

Read only

0 Likes
602

Hi Harmeet singh,

In my second conversation of posting,

I have explained why iam usign INTO CORRSPONDING

FIELDS OF TABLE is used.

I mean to say that i have used 5 select queries, after each

select and given logic i will be using commands as follows.

refresh:xit_analyst.

clear:xit_analyst.

it will be no contents in xit_analyst when new select query is

used.This select query is similiar to the first select query but

only by Differnet GROUP BY CLAUSE and fetching fields also

differnt.

Here xit_analyst type standard table of ztable.

All 5 queries iam using differnt group by clause fields.

since ztable has 9 key fields.

for example first select query iam using 3 key fields of ztable and 4 non key fields in group by clause.

in second select qurey lam using next 2 key fileds of ztable

and 3 non key fields in group by clause.

in third select qury iam usign next 3 key fields of ztable and

2 non key fieleds in group by clause.

All the select queries iam fetchign data from ztable but with differnt group by clause(differnt key fields and non key fileds).

I hope it is understood.

BestRegards,

S.Anilkumar