Percentage Totals in ALV
Moderators: Snowy, thx4allthefish, YuriT, Gothmog
Percentage Totals in ALV
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).
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).
I am not sure
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.

 Posts: 185
 Joined: Mon Nov 18, 2002 10:15 am
ALV Paint Row Color
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: IItem line; TTotal
clrtab TYPE slis_t_specialcol_alv. <<Color table
DATA: END OF itab.
2. Append color table 'clrtab' for total rows:
LOOP AT itab.
IF itabftype = 'T'.
CLEAR: wa_clrtab.
* wa_clrtabfieldname = ' '. <<Leave blank to paint whole row
wa_clrtabcolorcol = 5. "Green
wa_clrtabcolorint = 1.
wa_clrtabcolorinv = 0.
wa_clrtabnokeycol = 'X'. <<Also paint key columns
APPEND wa_clrtab TO itabclrtab.
MODIFY itab.
ENDIF.
ENDLOOP.
3. In layout structure build up, add one statement:
e05_ls_layoutcoltab_fieldname = 'CLRTAB'.
*You can refer to documentation for function module 'REUSE_ALV_GRID_DISPLAY'  parameter 'IS_LAYOUT' for more.
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: IItem line; TTotal
clrtab TYPE slis_t_specialcol_alv. <<Color table
DATA: END OF itab.
2. Append color table 'clrtab' for total rows:
LOOP AT itab.
IF itabftype = 'T'.
CLEAR: wa_clrtab.
* wa_clrtabfieldname = ' '. <<Leave blank to paint whole row
wa_clrtabcolorcol = 5. "Green
wa_clrtabcolorint = 1.
wa_clrtabcolorinv = 0.
wa_clrtabnokeycol = 'X'. <<Also paint key columns
APPEND wa_clrtab TO itabclrtab.
MODIFY itab.
ENDIF.
ENDLOOP.
3. In layout structure build up, add one statement:
e05_ls_layoutcoltab_fieldname = 'CLRTAB'.
*You can refer to documentation for function module 'REUSE_ALV_GRID_DISPLAY'  parameter 'IS_LAYOUT' for more.
Enjoy Fun of SAP
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.
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.
Solution is here...
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_FIELDCATALOGFIELDNAME = P1.
L_LT_FIELDCATALOGTABNAME = P2.
L_LT_FIELDCATALOGCOL_POS = P3.
L_LT_FIELDCATALOGKEY = P4.
L_LT_FIELDCATALOGDO_SUM = P5.
APPEND L_LT_FIELDCATALOG TO P_G_FIELDCAT.
ENDFORM. " format_field_catalog
This is really worked.
Hope this helps
G
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_FIELDCATALOGFIELDNAME = P1.
L_LT_FIELDCATALOGTABNAME = P2.
L_LT_FIELDCATALOGCOL_POS = P3.
L_LT_FIELDCATALOGKEY = P4.
L_LT_FIELDCATALOGDO_SUM = P5.
APPEND L_LT_FIELDCATALOG TO P_G_FIELDCAT.
ENDFORM. " format_field_catalog
This is really worked.
Hope this helps
G
Percentage Totals in ALV
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 by importing the object reference (CL_GUI_ALV_GRID) using the function module .
But I haven't tried the latter solution.
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'
Code: Select all
'GET_GLOBALS_FROM_SLVC_FULLSCR'
But I haven't tried the latter solution.
Percentage Totals in ALV
I have the same issue with percentages in the subtotal and total. More details on the coding would be greatly appreciated.