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

Row wise total using ALV OOPS

Hi experts,

My requirement is to display rowwise sum in ALV .We have option to do column wise sum by setting do_sum field in fieldcatalog. Do we have anything to do rowwise sum?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

9 Answers

  • Best Answer
    Posted on May 07, 2014 at 12:22 PM

    Hi,

    as far as I know, you can't set something like do_sum for calculating rowwise sums.

    You can add another column for the sum to your output structure and create the sum manually:

    FIELD-SYMBOLS <s_data> LIKE LINE OF gt_data.

    LOOP AT gt_data ASSIGNING <s_data>.

    <s_data>-total = <s_data>-comp1 + <s_data>-comp2 + <s_data>-comp3.

    ENDLOOP.

    If you use a field-symbol here, it will be more performant, if your internal table has many entries.

    If you already do a loop at your internal table somewhere before in the programm or you create your internal table row-by-row by appending them, better calculate the sum there to improve performance.

    Regards,

    Claudia

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 07, 2014 at 09:49 AM

    Hi,

    Are all fields currency or quantity fields?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi rajan,

      Try This code.

      Take another field (TOATL) <type your currencyor quantity fields> in your final internal table.

      In data filling loop.

      loop at <itab> into <wa>.

      w_final-f1 = wa-f1.

      w_final-f2 = wa-f2.

      w_final-f3 = wa-f3.

      w_final-f4 = wa-f4.

      w_final-f5 = wa-f5.

      w_final-total = w_final-f1 + w_final-f2 + w_final-f3 + w_final-f4 + w_final-f5.

      endloop.

      next display your fields.

  • Posted on May 07, 2014 at 11:14 AM

    Dear Ranjan,

    In ALV OOP no particular option(syntax or statement) for row wise total.

    Use same as procedural oriented code as.

    loop at it_final into wa_final.

    wa_final-f4 = wa_final-f1 + wa_final-f2 + wa_final-f3.

    modify it_final from wa_final index sy-tabix transporing f4.

    endloop.






    Regards,

    Abbas.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 07, 2014 at 03:20 PM

    Hi Ranjan,

    As of my knowledge, there is no direct method to calculate Row wise totals, I believe.

    If your requirement is as follow,

    Col1 Col2 Col3 Col4

    2 5 6 13

    4 5 3 12 (Col1 + Col2 + Col3)

    Then before displaying the output just loop the internal table and calculate the Total as above and place that value in last column and modify internal table.

    If user doesn't want it by default and he wants to see that whenever he required, just make one default layout without total Column.

    If my understanding was wrong, hope you can elaborate your query.

    Thanks & Regards,

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 07, 2014 at 10:57 AM

    hi ,

    1.u can use field symbol for row wise total .

    2.First collect all data in internal table than use field symbol.

    syntax:

    FIELD-SYMBOLS: <work area> TYPE table structure.

    LOOP AT internal table ASSIGNING <work area>.


    ENDLOOP.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 07, 2014 at 11:10 AM

    You have to do it manually.

    1. Create a new column to display total.
    2. Loop at your internal table. Calculate the totals and store in the new column.
    3. Modify the field catalog and add the total column.

    Regards,

    Ashish

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi

      U can use alv field catlog user command . put new button on PF -STATUS TOOL BAR .

      When User Press Button , Append Field Catlog Stuture dymically and Put Field Symbol.

      Regards ,

      Anil Singh

  • author's profile photo Former Member
    Former Member
    Posted on May 07, 2014 at 11:25 AM

    Process the data into internal table with one additional filed.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 09, 2014 at 04:14 AM


    Thank you all for your reply.I have resolved it now.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 09, 2014 at 04:48 AM

    HI,

    Plz provide solovtion which u did...

    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.