2014 May 07 10:47 AM
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?
2014 May 07 1: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
2014 May 07 10:49 AM
2014 May 07 10:51 AM
2014 May 07 11:07 AM
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.
2014 May 07 11: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.
2014 May 07 12:10 PM
You have to do it manually.
Regards,
Ashish
2014 May 07 12:35 PM
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
2014 May 07 12:14 PM
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.
2014 May 07 12:25 PM
Process the data into internal table with one additional filed.
2014 May 07 1: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
2014 May 07 4: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
2014 May 09 5:14 AM
2014 May 09 6:56 AM
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
2014 May 09 5:48 AM