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: 

Row wise total using ALV OOPS

Former Member
0 Kudos
1,320

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?

1 ACCEPTED SOLUTION

claudia_bolch
Explorer
0 Kudos
420

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

13 REPLIES 13

Former Member
0 Kudos
420

Hi,

Are all fields currency or quantity fields?

0 Kudos
420

Hi Satya,

Yes.They all are currency and quantity fields.

0 Kudos
420

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.

Former Member
0 Kudos
420

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.

former_member289261
Active Contributor
0 Kudos
420

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

0 Kudos
420

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

former_member194739
Active Participant
0 Kudos
420

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.

Former Member
0 Kudos
420

Process the data into internal table with one additional filed.

claudia_bolch
Explorer
0 Kudos
421

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

VijayaKrishnaG
Active Contributor
0 Kudos
420

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

Former Member
0 Kudos
420


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

0 Kudos
420

Hi,

please set the thread's status to anwered or assumed answered..While status is not answered other SCN members join the thread and want to try to help you solve your open issue.

Regards,

Klaus

Former Member
0 Kudos
420

HI,

Plz provide solovtion  which u did...