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: 

ALV Total and Percentage

Former Member
0 Kudos
83

Hi,

In my ALV report,I have 4 fields

matnr

maktx

menge1

menge2

In the end of report (column of menge1), i want only total

end of menge2 i want the value in percentage as = (Total of menge2 / total of menge1) * 100

I am using Fm : Reuse_alv_grid_display.

Can anybody suggest me how to do.

Thanks

Kumar

3 REPLIES 3

Former Member
0 Kudos
31

Hi ,

The simplest way of doing that would be to add the required data (sum and percentage) as the last record in the internal table and then display the table in ALV.

Regards

Arun

Former Member
0 Kudos
31

This message was moderated.

raymond_giuseppi
Active Contributor
0 Kudos
31

Use the following code in a PBO module (after set for first display) or in an adequate event handler.

data: total type ref to data, 
      subtotal1 type ref to data.
field-symbols: <total> like gt_sflight,
               <subtotal1> like gt_sflight.
call method grid1->get_subtotals 
  importing
    ep_collect00 = total
    ep_collect01 = subtotal1.
assign total->* to <total>. 
assign subtotal1->* to <subtotal1>.

Then update the <total> internal tables.

Look at [ALV Grid Control (BC-SRV-ALE)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf]

NB: If you add a last row to the report, don't forget to disable sort options in the ALV menu.

Regards