Skip to Content
0
Former Member
Sep 12, 2007 at 07:59 PM

Event BEFORE_LINE_OUTPUT with ALV FM

324 Views

I'm attempting to use the BEFORE_LINE_OUTPUT event to add "custom" calculations into my ALV subtotals. I've read through many posts on SDN about using the ALV events, but the form I'm using with BEFORE_LINE_OUTPUT doesn't seem to get processed. (I tried using event TOP_OF_PAGE, and I did get the form to get called).

Can anyone help with this, or give me some other option (other than switching to classes/methods) to add custom calculation in my subtotal? (Basically want to recalculate my percentages at the subtotal level).

Here's the code I have so far...

DATA: ls_events   TYPE slis_alv_event,   
lt_events   TYPE slis_t_event. 
 
* Get events
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
     IMPORTING
          et_events = lt_events.
READ TABLE lt_events WITH KEY name = 'BEFORE_LINE_OUTPUT'
     INTO ls_events.
 
* Add Form for event BEFORE_LINE_OUTPUT
ls_events-form = 'BEFORE_LINE_OUTPUT'.
MODIFY lt_events INDEX sy-tabix FROM ls_events.
 
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
             EXPORTING
*           I_INTERFACE_CHECK           = ' '
            i_callback_program          = repid
*           I_CALLBACK_PF_STATUS_SET    = 'ALV_STATUS_SET'
            i_callback_user_command     = callback_prg
            i_callback_top_of_page      = 'ALV_TOP_OF_PAGE'
*           I_CALLBACK_HTML_TOP_OF_PAGE = ' '
*           i_structure_name            = 'T510'    "DDIC-Bezug
*           I_BACKGROUND_ID             = 'ALV_WALLPAPER2'
*           I_GRID_TITLE                = sy-title
            is_layout                   = layout
            it_fieldcat                 = fieldcat[]
*           IT_EXCLUDING                =
*           IT_SPECIAL_GROUPS           =
*           it_sort                     = sortcat[]
*           IT_FILTER                   =
*           IS_SEL_HIDE                 =
*           I_DEFAULT                   = 'X'
            i_save                      = 'X'
*           is_variant                  = g_variant
           IT_EVENTS                   = LT_EVENTS " 09/04/2007
*           IT_EVENT_EXIT               =
*           IS_PRINT                    =
*           IS_REPREP_ID                =
*           I_SCREEN_START_COLUMN       = 5
*           I_SCREEN_START_LINE         = 5
*           I_SCREEN_END_COLUMN         = 120
*           I_SCREEN_END_LINE           = 30
*       IMPORTING
*           e_exit_caused_by_caller     = exit_caused_by_caller
*           es_exit_caused_by_user      = exit_caused_by_user
             TABLES
                  t_outtab                    = alvtab
                  EXCEPTIONS
                  program_error               = 1
                  OTHERS                      = 2.
 
FORM BEFORE_LINE_OUTPUT using p_lineinfo type slis_lineinfo .
 
  case p_lineinfo-tabname.
    when 'ALVTAB'.
      if p_lineinfo-subtot ne space.
        alvtab-am = 1234567. " sample data here
        modify ALVTAB index p_lineinfo-sumindex.
      endif.
      if p_lineinfo-endsum ne space.
        alvtab-am = 9999999.  " sample data here
      endif.
  endcase.
 
 
ENDFORM.                    " before_line_output

Thanks so much in advance,

Lisa