Application Development 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: 

summing fields

Former Member
0 Kudos

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

7 REPLIES 7

Former Member
0 Kudos

Hi

Write like this.

At end of matnr.

sum.

endat.

Thanks & Regards

Haritha.

0 Kudos

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.

0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

if u r using ALV report u can use slis_t_sortinfo.use this and add subtotal also.

Regards,

S.Nehru...

Former Member
0 Kudos

i myself found the solution...