Skip to Content
0
Former Member
Mar 04, 2009 at 04:54 PM

percentage in alv grid

864 Views

Hi all,

We are facing problem in calculating the percentage of two totals in grid-display.

Requirement is that we have three columns in a grid display using containers,

we got the total by do_sum = 'X' for first two columns and the third one is

percentage of the second in first.

I have used the following code for that after set_table_for_first_display method.

DATA : total TYPE REF TO data.

FIELD-SYMBOLS <ftotal> TYPE STANDARD TABLE.

DATA :  wa_tot TYPE ty_dcocd.    "intenal table type

CALL METHOD cl_alv_grid->get_subtotals
    IMPORTING ep_collect00 = total.  " getting the last row having totals

ASSIGN total->* TO <ftotal>.          
  LOOP AT <ftotal> INTO wa_tot.
 wa_tot-prcnt = wa_tot-sum_ol / wa_tot-sum * 100 . " calculating percentage from first two colums 
  MODIFY <ftotal> FROM wa_tot INDEX sy-tabix . "changing thefield symbol
endloop.

  CALL METHOD cl_alv_grid->refresh_table_display
    EXPORTING
      i_soft_refresh = 'X'.

if I check in <ftotal> ,Iam getting the changed last row with percentage but it is not reflecting in the output.what we need to do for that.

any sugestions wil make a difference.

Regards,

Anil.