‎2008 Nov 18 9:07 AM
Hi,
Can you please modify this code, i have performance issue for the following code.
Here: t_po is a final internal table.
select ekkobukrs ekkoebeln ekkolifnr ekkobsart " EKKO
ekkoernam ekkoaedat ekko~memory " EKKO
ekpoebelp ekpoidnlf ekpotxz01 ekpoloekz " EKPO
ekpoeffwr ekpomenge " EKPO
ekknsakto ekknps_psp_pnr " EKKN
ekknzekkn ekknmenge " EKKN
into (t_po-bukrs,t_po-ebeln,t_po-lifnr,t_po-bsart,
t_po-ernam,t_po-aedat,t_po-memory,
t_po-ebelp,t_po-idnlf,t_po-txz01,t_po-loekz,
t_po-effwr,t_po-menge,
t_po-sakto,t_po-ps_psp_pnr,
t_po-zekkn,t_po-menge1)
from ( ekko inner join ekpo
on ekkoebeln eq ekpoebeln )
inner join ekkn
on ekkoebeln eq ekknebeln
and ekpoebelp eq ekknebelp
for all entries in t_pspnr
where ekko~bukrs in s_bukrs and
ekko~lifnr in s_lifnr and
ekko~bsart in s_bsart and
ekko~aedat in s_aedat and
ekko~ernam in s_ernam and
ekpo~idnlf in s_idnlf and
ps_psp_pnr = t_pspnr-pspnr.
append t_po.
clear t_po.
endselect.
-
Another code:
sort t_po by bukrs idnlf ebeln ebelp.
loop at t_po.
select single post1 psphi into (t_po-post1,t_po-psphi) "Performance issue
from prps
where pspnr = t_po-ps_psp_pnr.
select single pspid into t_po-pspid ""Performance issue
from proj
where pspnr = t_po-psphi.
if t_po-pspid in s_pspid.
do nothing
else.
delete t_po index sy-tabix.
continue.
endif.
Get invoiced amount for a PO line item
select dmbtr shkzg into (ekbe-dmbtr,ekbe-shkzg) ""Performance issue
from ekbe
where ebeln = t_po-ebeln and
ebelp = t_po-ebelp and
vgabe = '2'.
if ekbe-shkzg = 'H'.
ekbe-dmbtr = ekbe-dmbtr * -1.
endif.
t_po-invamt = t_po-invamt + ekbe-dmbtr.
endselect. ""Performance issue
if not t_po-menge eq 0.
t_po-polinamt = t_po-effwr * ( t_po-menge1 / t_po-menge ).
endif.
t_po-amtopen = t_po-polinamt - t_po-invamt.
modify t_po index sy-tabix.
clear: t_po,prps,ekbe,proj.
endloop.
‎2008 Nov 18 9:14 AM
HI,
Instead of selecting each fields and putting it in each fileds in internal table, we can select the fields and put it into the internal table which contains the required fields.
Eg.
TYPES: begin of itab,
vorna type vorna,
nachn type nachn,
end of itab.
data: wt_itab type table of itab.
select vorna, nachn into table wt_itab from pa0002 where cond.
This increase the performance because it wont take time to match the each fields given after the table statement.
Regards,
Rani.
‎2008 Nov 18 9:15 AM
Create a non-unique or a secondary index using Se11 on the table with the fields you are using in your select clause.
Run St05 again after creating the index and there will be improvement in performance.
‎2008 Nov 18 9:36 AM
Hi,
First and foremost you need to remove the endselect and instead use into table .
Then before the query is called, check that the table t_pspnr is not empty.
Instead of doing a select inside the loop, select the data once in a internal table and read it within the loop. in your code the tables are prps ekbe
regards,
Advait
‎2008 Nov 18 10:08 AM
Hi,
Please declare ur internal table in the order in which you are selecting.
and use into table itab instead of mentioning each and every field.
And also avoid using select endselect. instead u can use into table itab option with the select statement.
Please use
'If not t_pspnr is intial'.
before using for all entries in t_pspnr.
Hope this helpful.
Thanks & Regards,
Sudheer.
Edited by: sudheer kumar on Nov 18, 2008 11:09 AM