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

regarding sum

Hi,

I have selected mblnr menge meins matnr and werksfrom mseg and loaded into a internal table now i have to add the menge field corresponding to matnr kindly help

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 02:40 PM

    Hi,

    Could you please more specific about requirement.

    Thanks,

    Sriram Ponna.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 02:42 PM

    Use COLLECT - loop your internal table and use keyword collect to collect (i.e. summarize the data) into another table.

    loop t_detail into h_detail.

    move-corresponding h_detail to h_summary.

    collect h_summary into t_summary.

    clear h_summary.

    clear h_detail.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 02:45 PM

    Hi,

    Below code should help you. One caution. Please SORT internal table before using this statement. Also, use MATNR as the first field, if you want to get menge for a particular matnr.

    Loop at Itab.

    at new matnr.

    sum.

    l_menge = itab-menge. " This statement adds menge for all same matnr

    endloop.

    <b><REMOVED BY MODERATOR></b>

    Let me know if you need more details.

    Regards

    Sudhaker

    Message was edited by:

    Alvaro Tejada Galindo

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      For the Matnr HALB_2_02 i have two menge values 200 and 8 i just gave the below coding to sum up the menge field

      loop at t_mseg.

      AT NEW MATNR.

      sum.

      t_mseg1-menge = t_mseg-menge.

      endat.

      endloop.

      but its not working .... i don't know where i am doing the mistake.

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 10:49 AM

    Hi,

    Correction

    sum.

    t_mseg-menge = t_mseg-menge.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 10:52 AM

    Hi Beginner,

    First of all, in order to add the values of all the menge for a particualr matnr,it would be better to use control loevel statements like AT NEW.

    But in case,you are unable to achieve it with this,then I would suggest to have a loop insidea loop and then compare the matnr and for all the same matnr,sum up the menge and then put it as one value.

    Like:

    Loop at itab into wa.

    Loop at itab1 into wa1.

    if wa-matnr = wa1-matnr.

    wa-menge = wa-menge + wa1-menge.

    endif.

    endloop.

    endloop.

    In case you have any further clarifications,do let me know.

    Regards,

    Puneet Jhari.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 21, 2007 at 10:54 AM

    Hi ,

    If ur all other fileds say meins werks mblnr have the same value ..then

    sort t_mseg by matnr.

    loop at t_mseg.

    collect t_mseg..

    endloop.

    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.