‎2009 Feb 24 11:53 AM
Hi Experts,
I want to improve one report performance.
LOOP AT it_data.
SELECT SUM( omeng ) AS omeng
FROM vbbe INTO it_data-op_so_qty
WHERE matnr = it_data-matnr
AND werks = it_data-werks
AND lgort = it_data-lgort
AND ( vbtyp = 'C' OR vbtyp = 'I' )
AND sobkz = ' '.
by using matnr we have to calculate total amounts(OMENG) for each material number which we got values from loop.
How to improve performance for these statements.
Pls help me.
THanks,
Madhu.
Please provide a more informative subject. there are lots of performance issues in the forums.
Moving to the correct forum.
Edited by: Rob Burbank on Feb 24, 2009 9:58 AM
‎2009 Feb 24 11:55 AM
Hi:
Do like this
SELECT matnr SUM( omeng ) AS omeng
FROM vbbe INTO it_data-op_so_qty
for all entries of it_data
WHERE matnr = it_data-matnr
AND werks = it_data-werks
AND lgort = it_data-lgort
AND ( vbtyp = 'C' OR vbtyp = 'I' )
AND sobkz = ' '
group by matnr
Regards
Shashi
‎2009 Feb 24 11:55 AM
Hi,
Dont use select statement in LOOP,
just use select with for all entries of it_data.
Regards,
Jyothi
‎2009 Feb 24 11:58 AM
Hi,
try like this..use one more internal table like it_data1 which is of type it_data
if not it_data[] is initial.
SELECT SUM( omeng ) AS omeng
FROM vbbe INTO it_data1
for all entries in it_data
WHERE matnr = it_data-matnr
AND werks = it_data-werks
AND lgort = it_data-lgort
AND ( vbtyp = 'C' OR vbtyp = 'I' )
AND sobkz = ' '.
endif.
regards,
Nagaraj
‎2009 Feb 24 11:59 AM
Hi,
Try the below code,
select matnr werks lgort vbtyp from vbbe
INTO it_data-op_so_qty
for all entries in it_data
WHERE matnr = it_data-matnr
AND werks = it_data-werks
AND lgort = it_data-lgort
AND ( vbtyp = 'C' OR vbtyp = 'I' )
AND sobkz = ' '.
if sy-subrc = 0.
loop at in it_data into wa_in it_data.
at end of lgort.
SUM.
Append to other temp ITAB
endloop.
endif.
When preparing final ITAB.
loop at it_data.
Read data from it_data-op_so_qty
endloop.
Regards,
Sunil
‎2009 Feb 24 12:01 PM
You can use this in case you dont need to perform any operations on the data
SELECT matnr SUM( omeng ) AS omeng
FROM vbbe INTO it_data-op_so_qty
for all entries of it_data
WHERE matnr = it_data-matnr
AND werks = it_data-werks
AND lgort = it_data-lgort
AND ( vbtyp = 'C' OR vbtyp = 'I' )
AND sobkz = ' 'or else
Rather than writing the select statement inside the loop .
Fetch all the records before loop using select statement once.
Then during the loop you can read the table for the data and you can manupulate the data and then update the internal table.
Hope this serves your purpose
Thanks & Regards,
Lalit Mohan Gupta.
‎2009 Feb 24 12:08 PM
Hi Experts,
By using above code i am getting error like
' The field "VBBEMATNR from the select list is missing in the group BY clause. is missing in the group by clause. is missing in the GROUP BY clause is "VBBEMANDT" .
Thanks,
Kaladhar.
Edited by: madhu on Feb 24, 2009 1:08 PM
‎2009 Feb 24 12:14 PM
Hi,
take a differnt internal table as itab1 which will have only two fields
matnr and omeng.
i belive the internal table it_Data has the folliwng fields.
matnr
werks
lgort
SELECT matnr SUM( omeng ) AS omeng
FROM vbbe INTO it_data1
for all entries of it_data
WHERE matnr = it_data-matnr
AND werks = it_data-werks
AND lgort = it_data-lgort
AND ( vbtyp = 'C' OR vbtyp = 'I' )
AND sobkz = '
Regards,
Nagaraj
‎2009 Feb 24 1:03 PM
Try with this
SELECT matnr SUM( omeng ) AS omeng
FROM vbbe INTO it_data-op_so_qty
for all entries of it_data
WHERE matnr = it_data-matnr
AND werks = it_data-werks
AND lgort = it_data-lgort
AND ( vbtyp = 'C' OR vbtyp = 'I' )
AND sobkz = ' '
group by vbbe~matnr.
‎2009 Mar 06 9:51 AM
Hi,
dont write select statement in the loop.
check below links for preformance tunning
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abap%2bperformance%2band%2btuning
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/performance%2btuning
Regards,
Madhu
‎2009 Mar 06 10:50 AM
instead using select sum(........) populate all data into internal table and then use control break (at end of ....sum endat)statements in loop and endloop