This website is not affiliated with, sponsored by, or approved by SAP AG.

Percentage Totals in ALV

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Percentage Totals in ALV

Postby Alfredo Doforno » Fri Feb 07, 2003 7:55 am

Hello to everyone.
I have a problem when working with ALV.
One of the columns ot the information is a percentage, which is calculated as a result of two other columns which are also available in the information.
When I use ALV to get totals and subtotals, the problem is that in order to calculate the percentage total, he sums all the percentages. That´s obviously wrong.
Is there a possibility to get the percentages right in the total lines?.
I also have the same problem when exporting the information to a Pivot table in Excel form ALV.
Is there a possibility to do it correctly just in Excel?.

Thank you very much. Regards from Seville (Spain).
Alfredo Doforno
 

I am not sure

Postby MBS » Fri Feb 07, 2003 8:04 am

I think u need to write the code explicitly. i faced the same type of problem but its different. calc. the average and it should be o/p in alv screen. this facility(average Calc.) is not there in ALV. so i think u need to write a code.
:roll:
MBS
 

Postby VenuKoganti » Tue Feb 11, 2003 6:15 pm

Atleast till 4.6C2, its not possible.
thanks,
Venu
VenuKoganti
 
Posts: 185
Joined: Mon Nov 18, 2002 10:15 am

ALV Paint Row Color

Postby pploo » Tue Feb 11, 2003 10:00 pm

Add one point:
After you create total rows manually, you can paint them with corresponding colors to make them look more 'real'.

STEPS:
1. In your output internal table, add one field for color table like:
DATA: BEGIN OF itab.
INCLUDE STRUCTURE sflight.
DATA: ftype(1), <<Field type: I-Item line; T-Total
clrtab TYPE slis_t_specialcol_alv. <<Color table
DATA: END OF itab.

2. Append color table 'clrtab' for total rows:
LOOP AT itab.
IF itab-ftype = 'T'.
CLEAR: wa_clrtab.
* wa_clrtab-fieldname = ' '. <<Leave blank to paint whole row
wa_clrtab-color-col = 5. "Green
wa_clrtab-color-int = 1.
wa_clrtab-color-inv = 0.
wa_clrtab-nokeycol = 'X'. <<Also paint key columns
APPEND wa_clrtab TO itab-clrtab.

MODIFY itab.
ENDIF.
ENDLOOP.

3. In layout structure build up, add one statement:
e05_ls_layout-coltab_fieldname = 'CLRTAB'.

*You can refer to documentation for function module 'REUSE_ALV_GRID_DISPLAY' - parameter 'IS_LAYOUT' for more.
--Enjoy Fun of SAP--
pploo
 
Posts: 152
Joined: Mon Oct 21, 2002 12:35 am
Location: Shanghai, China

Thanks to all of you for your replies

Postby Alfredo Doforno » Tue Feb 25, 2003 7:47 am

Thanks to all of you for your replies
Alfredo Doforno
 

Postby sapmanie » Thu Apr 24, 2003 8:15 am

I'm facing the same problem...

Is it possible to put your own calculation into a total\subtotal field?

e.g. when user clicks sum or subtotalbutton, rather than summing the percentage column, can you get the totals of the other columns, calculate the percentage from them, and put it into the total field in the percentage column?

I'm using the REUSE* FMs. Thanks.
sapmanie
 

Solution is here...

Postby ccsabaper » Thu Apr 24, 2003 4:38 pm

Hi,

The percentage can be displayed using a small technique. While peforming the Field catalog, populate the field DO_SUM = 'C'. This will give the output as the Percentage(Mean). This will work only for amount or numeric fields.

Eg: Perform: format_field_catalog
using 'Total Amount' 'I_ALVTAB' '8' ' ' 'C' G_FIELDCAT[].

Here I_ALVTAB is the internal table where the data has been stored.
'8' is the column position.
G_FIELDCAT[] type slis_t_fieldcat_alv.

FORM format_field_catalog USING P1
P2
P3
P4
P5
P_G_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

STATICS: L_LT_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV.

CLEAR: L_LT_FIELDCATALOG.

L_LT_FIELDCATALOG-FIELDNAME = P1.
L_LT_FIELDCATALOG-TABNAME = P2.
L_LT_FIELDCATALOG-COL_POS = P3.
L_LT_FIELDCATALOG-KEY = P4.
L_LT_FIELDCATALOG-DO_SUM = P5.

APPEND L_LT_FIELDCATALOG TO P_G_FIELDCAT.

ENDFORM. " format_field_catalog

This is really worked.
Hope this helps
G
ccsabaper
 
Posts: 43
Joined: Wed Oct 30, 2002 10:37 am
Location: Boston

Postby sapmanie » Fri Apr 25, 2003 4:37 am

DO_SUM can only accept a SPACE or X, so maybe you're thinking of another field? I tried it with C anyway, but nothing happened, as expected. Thanks.
sapmanie
 

Postby will.sun » Wed Feb 22, 2006 10:54 am

Great solution!
it really works!
do you know where can find the documentation for the field do_sum ?
will.sun
 

Postby will.sun » Wed Feb 22, 2006 10:12 pm

I found when DO_SUM = 'C'
it calculate the average value for the colum, I don't think it will calculate the right percentage.
will.sun
 

Percentage Totals in ALV

Postby vpj » Wed Dec 27, 2006 3:41 am

This should help
www.xvpj.net

You can use your own formulas for subtotals and it's pretty simple. Also, you can implement this with
Code: Select all
'REUSE_ALV_GRID_DISPLAY'
by importing the object reference (CL_GUI_ALV_GRID) using the function module
Code: Select all
'GET_GLOBALS_FROM_SLVC_FULLSCR'
. :)
But I haven't tried the latter solution. :P
vpj
 
Posts: 1
Joined: Wed Dec 27, 2006 3:26 am
Location: Sri Lanka

Percentage Totals in ALV

Postby agilles » Wed Jun 27, 2007 9:55 am

I have the same issue with percentages in the subtotal and total. More details on the coding would be greatly appreciated.
agilles
 
Posts: 3
Joined: Tue Oct 25, 2005 11:00 am


Return to ABAP

Who is online

Users browsing this forum: No registered users and 9 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.