This website is not affiliated with, sponsored by, or approved by SAP AG.
Development (ABAP Development WorkBench, ABAP/4 programming)
12 posts • Page 1 of 1
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).
Add one point:
After you create total rows manually, you can paint them with corresponding colors to make them look more 'real'.
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'.
* 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.
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--
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.
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
P_G_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
STATICS: L_LT_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV.
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
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.
it really works!
do you know where can find the documentation for the field do_sum ?
I found when DO_SUM = 'C'
it calculate the average value for the colum, I don't think it will calculate the right percentage.
This should help
You can use your own formulas for subtotals and it's pretty simple. Also, you can implement this with
But I haven't tried the latter solution.
12 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 10 guests