Calculating values for ALV total lines

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

ocvantol
Posts: 929
Joined: Tue Oct 22, 2002 3:19 am
Location: The Hague

Post by ocvantol » Wed Dec 07, 2005 6:52 am

Can this be true: I tested the same with REUSE_ALV_LIST_DISPLAY and it works...

Why the %#** does is not work for REUSE_ALV_GRID_DISPLAY?
Oscar.

ocvantol
Posts: 929
Joined: Tue Oct 22, 2002 3:19 am
Location: The Hague

Post by ocvantol » Thu Mar 30, 2006 10:45 pm

Does someone have an idea how to get this working for REUSE_ALV_GRID_DISPLAY?
Oscar.

bingsoliven
Posts: 8
Joined: Sun Oct 01, 2006 11:23 pm

Post by bingsoliven » Mon Oct 02, 2006 1:01 am

Hi adsz73 ! i also have the same problem. Would you mind if I ask a copy of your code? I was thinking it might be agreat help. Thanks!

Senior
Posts: 43
Joined: Wed Nov 20, 2002 8:41 am
Location: Istanbul, TURKEY

Post by Senior » Thu Oct 05, 2006 12:40 am

ocvantol wrote:Does someone have an idea how to get this working for REUSE_ALV_GRID_DISPLAY?
Sorry guys, you can't use this technique with ALV GRID display, because grid calculates the subtotals on the front-end, so you can't change them from the server.

Here is a short summary of the above messages:

Your internal table should have a header line and you must send it to the ALV LIST function with its header line, ie.

Code: Select all

data: t_outtab type something with header line.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' 
     ...
     TABLES 
          t_outtab = t_outtab
     ...
Don't use t_outtab[].


Handle the BEFORE_LINE_OUTPUT event using the it_events parameter of the REUSE function:

Code: Select all

* Add Form for event BEFORE_LINE_OUTPUT 
  ls_events-name = 'BEFORE_LINE_OUTPUT'.
  ls_events-form = 'ALV_BEFORE_LINE_OUTPUT'. 
  append ls_events to lt_events.
Write the event handler like this:

Code: Select all

form alv_before_line_output using p_lineinfo type slis_lineinfo. 
  if p_lineinfo-subtot ne space. 
    t_outtab-dmbtr = 1234567. 
    t_outtab-maktx = 'Hello!'. 
    modify t_outtab index p_lineinfo-sumindex. 
  endif. 
  if p_lineinfo-endsum ne space. 
    t_outtab-dmbtr = 9999999. 
    t_outtab-maktx = 'Ooo, great total'. 
  endif. 
endform.
You can change all fields that are printed at the sum line, including fields that are sorted and causes the subtotal. Changes to other fields are meaningless.

And you can use the AFTER_LINE_OUTPUT event to write further output on screen.

y0sh1
Posts: 1
Joined: Sun Oct 07, 2007 3:48 pm

Custom calculation of totals on the ALV GRID

Post by y0sh1 » Sun Oct 07, 2007 4:06 pm

Hi, I wrote a sample program, for custom calculation of totals on the ALV GRID. Its works. You can see that on my homepage. The forum engine restrict me to write links directly, therefore:
y0sh1 dot extra dot hu <- my homepage's address

abap_doctor
Posts: 6955
Joined: Thu Mar 25, 2004 11:29 am
Location: Airstrip One

Post by abap_doctor » Mon Oct 08, 2007 4:07 am

Let's hope they're still looking one year later.... :?

Why not post the code here? :?
The Doc
Tuly Idiot Magna Grand Docot Image

Post Reply