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: 

Own total text in OO-GRID

Former Member
0 Kudos

Hi,

i will give the total-sum (not subtotal) line in OO-GRID an own text. Is it possible?

Regards, Dieter

1 REPLY 1

Former Member
0 Kudos

Hi Dieter,

nowadays I'm facing the same problem. I have explored whole class CL_GUI_ALV_GRID and there is not any standard possibility to put own text in total line. But there is one solution, which is not ideal but functional - using another subtotal (I'm using function module REUSE_ALV_GRID_DISPLAY instead of class CL_GUI_ALV_GRID directly, but the principle is almost the same):

in field catalog put any empty hidden field (this field must exist in your output table too!):

  CLEAR l_fieldcat.
  l_fieldcat-fieldname = 'TOTAL_TEXT'.
  l_fieldcat-seltext_s = 'Total'.
  l_fieldcat-seltext_m = 'Total'.
  l_fieldcat-seltext_l = 'Total'.
  l_fieldcat-reptext_ddic = 'Total'.
  l_fieldcat-no_out = 'X'.
  APPEND l_fieldcat TO i_fieldcat.

define subtotal by this field, it forces event SUBTOTAL_TEXT:

  CLEAR l_sort.
  l_sort-spos = 1.
  l_sort-fieldname = 'TOTAL_TEXT'.
  l_sort-up = 'X'.
  l_sort-subtot = 'X'.
  APPEND l_sort TO i_sort.

forbid making totals:

  s_layout-no_totalline = 'X'.

register event SUBTOTAL_TEXT:

  CLEAR l_event.
  l_event-name = 'SUBTOTAL_TEXT'.
  l_event-form = 'PROCESS_SUBTOTAL_TEXT'.
  APPEND l_event TO i_event.

form for processing event SUBTOTAL_TEXT:

*---------------------------------------------------------------------*
*       FORM process_subtotal_text                                    *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  P_LINE                                                        *
*  -->  P_SST                                                         *
*---------------------------------------------------------------------*
FORM process_subtotal_text USING p_line p_sst TYPE slis_subtot_text.
  DATA lcl_grid TYPE REF TO cl_gui_alv_grid.

  DATA: l_i_fieldcat  TYPE lvc_t_fcat,
        l_wa_fieldcat TYPE lvc_s_fcat,
        l_tabix       LIKE sy-tabix.

  CASE p_sst-criteria.
    WHEN 'TOTAL_TEXT'.
      p_sst-display_text_for_subtotal = 'Your own text'.
" This is necessary to avoid users to play with this field (in my case,
" if the TECH attribute was set in definition of field catalog, system
" doesn't display the text)
      IF g_set_tech IS INITIAL. "Change field catalog only once
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
             IMPORTING
                  e_grid = lcl_grid.
        CALL METHOD lcl_grid->get_frontend_fieldcatalog
          IMPORTING
            et_fieldcatalog = l_i_fieldcat.
        READ TABLE l_i_fieldcat WITH KEY fieldname = 'TOTAL_TEXT'
             INTO l_wa_fieldcat.
        l_tabix = sy-tabix.
        l_wa_fieldcat-tech = 'X'.
        MODIFY l_i_fieldcat FROM l_wa_fieldcat INDEX l_tabix.
        CALL METHOD lcl_grid->set_frontend_fieldcatalog
          EXPORTING
            it_fieldcatalog = l_i_fieldcat.
        g_set_tech = 'X'.
      ENDIF.
    WHEN OTHERS. "Another subtotals
  ENDCASE.
ENDFORM.

create ALV GRID:

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'...

Regards,

Petr