Skip to Content
author's profile photo Former Member
Former Member

summing fields

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 08:40 AM

    Hi

    Write like this.

    At end of matnr.

    sum.

    endat.

    Thanks & Regards

    Haritha.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 08: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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 08:43 AM

    Hi,

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

    Regards,

    S.Nehru...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 10:17 AM

    i myself found the solution...

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.