Skip to Content
0
Former Member
May 08, 2008 at 09:03 AM

is there any alternative for this code to increase performance

54 Views

hi, i want alternate code for this to increase performance.

DATA : BEGIN OF itab OCCURS 0,

matnr LIKE zcst-zmatnr,

checked TYPE i,

defected TYPE i,

end of itab.

SELECT DISTINCT zmatnr FROM zcst INTO TABLE itab WHERE

  • zmatnr IN s_matnr AND

zwerks EQ p_plant AND

zcastpd IN s_castpd AND

zcatg IN s_categ.

LOOP AT itab.

ind = sy-tabix.

SELECT COUNT( DISTINCT zcst~zcastn )

FROM zcst INNER JOIN zvtrans

ON ( zcstzcastn = zvtranszcastn AND

zcstzmatnr = zvtranszmatnr AND

zcstzwerks = zvtranszwerks AND

zcstgjahr = zvtransgjahr )

INTO itab-checked

WHERE

zcst~zmatnr = itab-matnr AND

zcst~zwerks EQ p_plant AND

zcastpd IN s_castpd AND

zcatg IN s_categ.

SELECT COUNT( DISTINCT zcst~zcastn )

FROM zcst INNER JOIN zvtrans

ON ( zcstzcastn = zvtranszcastn AND

zcstzmatnr = zvtranszmatnr AND

zcstzwerks = zvtranszwerks AND

zcstgjahr = zvtransgjahr )

INTO itab-defected

WHERE

zcst~zmatnr = itab-matnr AND

zcst~zwerks EQ p_plant AND

zcastpd IN s_castpd AND

zcatg IN s_categ AND

zvtrans~zdcode <> ' '.

MODIFY itab INDEX ind.

ENDLOOP.

i think, select within loop is reducing the performance

pls reply