2012 May 07 9:04 AM
Dear ABAP experts;
I was required to create a new field in a Z* table and fill those data as its required. However, my ABAP report runs sooo slow and it will take forever for 5 million datas.
I need a performance tuning for this code but I couldnt really figure that out.
Here is my code:
tables: blpk, mseg, zpp_20.
data: itab type table of zpp_20 with header line,
wa_blpk like blpk.
select-options: s_prtnr for zpp_20-prtnr,
s_mjahr for zpp_20-mjahr.
parameters p_werks like zpp_20-werks OBLIGATORY.
start-of-selection.
select * from zpp_20
into table itab
where prtnr in s_prtnr
and mjahr in s_mjahr
and werks eq p_werks.
loop at itab. "I loop itab to fill out the new field that I added.
select single * from blpk
into wa_blpk
where prtnr = itab-prtnr
and vaart = 'B'.
if sy-subrc eq 0.
select single lgort from mseg
into itab-alort
where mblnr = itab-belnr
and mjahr = itab-mjahr
and matnr = itab-matnr
and werks = itab-werks
and ( bwart = '131' or bwart = '132' ).
if sy-subrc eq 0.
modify itab.
update zpp_20 set alort = itab-alort where
belnr = itab-belnr and
mjahr = itab-mjahr and
matnr = itab-matnr and
werks = itab-werks.
commit work.
else.
continue.
endif.
else.
continue.
endif.
endloop.
Moderator Message: Please provide more details viz., SQL trace, Runtime analysis - SE30/SAT - snapshot etc.
Thanks in advance.
Talha
Message was edited by: Suhas Saha
2012 May 07 9:16 AM
Hi,
Remove your selection inside the loop. Use FOR ALL ENTRIES. Then, use READ TABLE to get those values. Use F1 for help.
Jake.
2012 May 07 9:20 AM
hi
inside loop select statement is performance issue in the place of select query use read table
Please the follow or search the performance issues points search in sdn some therds are avilable plz follow those
Regards
mahesh
2012 May 07 9:23 AM
Hi Talha,
At this part, avoid select * if you won't use all fields of zpp_20.
" select * from zpp_20
into table itab
where prtnr in s_prtnr
and mjahr in s_mjahr
and werks eq p_werks."
Here, delete loop itab and use for all entries.
" loop at itab. "I loop itab to fill out the new field that I added.
select single * from blpk
into wa_blpk..."
You can also use SAT or se30 in order to trace and optimize your program's performance.
Kind regards.
2012 May 07 9:25 AM
yes i agree with Jake Jason Dacquel .
you can also visit following ABAP Performance Standards link:
<link to blocked site removed by moderator>
Message was edited by: Thomas Zloch
2012 May 07 9:25 AM
2012 May 07 9:36 AM