01-10-2008 8:37 AM
hi all,
i have selected material documents, material no and quantity form mseg table based on movement type. now i need to sum the quantities for same material number. how shall i do this please help me.
regards
karthi
01-10-2008 8:40 AM
Hi
Write like this.
At end of matnr.
sum.
endat.
Thanks & Regards
Haritha.
01-10-2008 8:50 AM
hi,
if i'm having 4 values in same material number
like
mno mdoc quantity movement typt
11010 1234 100 100
11010 1235 100 100
11010 1236 200 100
i need to get
material no quantity
11010 400
like this......
karthi.
01-10-2008 8:50 AM
hi,
if i'm having 4 values in same material number
like
mno mdoc quantity movement typt
11010 1234 100 100
11010 1235 100 100
11010 1236 200 100
i need to get
material no quantity
11010 400
like this......
karthi.
01-10-2008 8:57 AM
Hi Karthi,
As per the query raised by you, for obtaining the output as required by you .
Checkk this sample code.
Sample :
************************************************************************
sort it_total by matnr eindt.
loop at it_total into wa_total.
if sy-tabix = 1.
move wa_total to wa_same.
APPEND wa_same to it_same.
else.
if wa_total-matnr = wa_same-matnr and
wa_total-eindt = wa_same-eindt.
MOVE wa_total to wa_same.
APPEND wa_same to it_same.
else.
sort it_same by aedat DESCENDING.
READ TABLE it_same INTO wa_same INDEX 1.
move wa_same-name1 to v_name.
loop at it_same into wa_same.
move wa_same-matnr to wa_itab-matnr.
move wa_same-menge to wa_itab-menge.
move wa_same-eindt to wa_itab-eindt.
collect wa_itab into it_itab.
ENDLOOP.
loop at it_same INTO wa_same.
at end of menge.
sum.
summation and deletion of the duplcate records and finally move that single record to the new internal table
endat.
endloop.
Read TABLE it_itab into wa_itab index 1.
move wa_itab-matnr to wa_output-matnr.
move wa_itab-menge to wa_output-menge.
move wa_itab-eindt to wa_output-eindt.
move v_name to wa_output-name1.
append wa_output to it_output.
clear wa_output.
refresh it_same.
refresh it_itab.
clear v_name.
MOVE wa_total to wa_same.
APPEND wa_same to it_same.
ENDIF.
For last record
at last.
sort it_same by aedat DESCENDING.
READ TABLE it_same INTO wa_same INDEX 1.
move wa_same-name1 to v_name.
loop at it_same into wa_same.
move wa_same-matnr to wa_itab-matnr.
move wa_same-menge to wa_itab-menge.
move wa_same-eindt to wa_itab-eindt.
collect wa_itab into it_itab.
ENDLOOP.
Read TABLE it_itab into wa_itab index 1.
move wa_itab-matnr to wa_output-matnr.
move wa_itab-menge to wa_output-menge.
move wa_itab-eindt to wa_output-eindt.
move wa_lfa1-name1 to wa_output-name1.
append wa_output to it_output.
CLEAR wa_output.
endat.
Process end for last record
endif.
endloop.
***********************************************************************
Hope this will resolve your Query.
Reward all the helpful answers.
Regards
Nagaraj T
01-10-2008 8:41 AM
using control statements we find total value of the material no.
data total type i value '0'.
(Sort the itab by material no)
loop itab.
total = total+qty.
at end of <material no>
u will get total as total qty.
(again initialize the total as 0.)
total =0.
endloop.
Madhavi
01-10-2008 8:43 AM
Hi,
if u r using ALV report u can use slis_t_sortinfo.use this and add subtotal also.
Regards,
S.Nehru...
01-29-2008 10:17 AM