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 issue

Former Member
0 Likes
1,282

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

10 REPLIES 10
Read only

Former Member
0 Likes
1,251

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

Read only

jyothi_anagani
Active Contributor
0 Likes
1,251

Hi,

Dont use select statement in LOOP,

just use select with for all entries of it_data.

Regards,

Jyothi

Read only

former_member404244
Active Contributor
0 Likes
1,251

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

Read only

Former Member
0 Likes
1,251

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

Read only

Former Member
0 Likes
1,251
  • 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.

Read only

Former Member
0 Likes
1,251

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

Read only

0 Likes
1,251

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

Read only

0 Likes
1,251

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.

Read only

Former Member
0 Likes
1,251
Read only

Former Member
0 Likes
1,251

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