Skip to Content
0
Former Member
Nov 28, 2008 at 01:52 PM

summation query

19 Views

i am doing this to get the adittion of the fields for a particular customer and displaying it.if the flag is set,it will add the respective field.this customer is shown by making the group.

please help.

i cant use at end,at new as my field is not the first field in the niternal table.neither can sum it as to be displayed after every change in the customer.i am not displaying this for the same customer.

DATA:IT_OUTREC2 LIKE OUTREC OCCURS 0 WITH HEADER LINE,

WA_OUTREC2 LIKE IT_OUTREC2,

IT_OUTREC1 LIKE OUTREC OCCURS 0 WITH HEADER LINE.

data:L_AMT1 like wa_outrec-rast1,

L_AMT2 like wa_outrec-rast2,

L_AMT3 like wa_outrec-rast3,

L_AMT4 like wa_outrec-rast4,

L_AMT5 like wa_outrec-rast5,

L_AMT6 like wa_outrec-rast6,

L_AMT7 like wa_outrec-rast7,

L_AMT8 like wa_outrec-sum1.

data:l_kunnr like wa_outrec-kunnr.

data:wa_outrec1 like outrec.

if p_con = 'X'.

sort outrec by kunnr.

loop at outrec into wa_outrec.

if l_kunnr NE wa_outrec-kunnr.

if sy-tabix <> 1.

wa_outrec2 = wa_outrec.

wa_outrec2-rast1 = l_amt1.

wa_outrec2-rast2 = l_amt2.

wa_outrec2-rast3 = l_amt3.

wa_outrec2-rast4 = l_amt4.

wa_outrec2-rast5 = l_amt5.

wa_outrec2-rast6 = l_amt6.

wa_outrec2-rast7 = l_amt7.

wa_outrec2-sum1 = l_amt8.

wa_outrec2-kunnr = l_kunnr.

clear wa_outrec2-bukrs.

append wa_outrec2 to IT_outrec2.

endif.

l_kunnr = wa_outrec-kunnr.

wa_outrec2 = wa_outrec.

endif.

L_AMT1 = L_AMT1 + wa_outrec-rast1.

L_AMT2 = L_AMT2 + wa_outrec-rast2.

L_AMT3 = L_AMT3 + wa_outrec-rast3.

L_AMT4 = L_AMT4 + wa_outrec-rast4.

L_AMT5 = L_AMT5 + wa_outrec-rast5.

L_AMT6 = L_AMT6 + wa_outrec-rast6.

L_AMT7 = L_AMT7 + wa_outrec-rast7.

L_AMT8 = L_AMT8 + wa_outrec-sum1.

endloop.

wa_outrec2 = wa_outrec.

wa_outrec2-rast1 = l_amt1.

wa_outrec2-rast2 = l_amt2.

wa_outrec2-rast3 = l_amt3.

wa_outrec2-rast4 = l_amt4.

wa_outrec2-rast5 = l_amt5.

wa_outrec2-rast6 = l_amt6.

wa_outrec2-rast7 = l_amt7.

wa_outrec2-sum1 = l_amt8.

wa_outrec2-kunnr = l_kunnr.

clear wa_outrec2-bukrs.

append wa_outrec2 to IT_outrec2.

endif.

refresh outrec[].

outrec[] = IT_outrec2[].

if P_CON = ' '.

endif.

IF RAD1 = 'X'.

SORT OUTREC BY BUKRS.

endif.

IF RAD2 = 'X'.

SORT OUTREC BY KUNNR.

ENDIF.