Skip to Content
author's profile photo Former Member
Former Member

REG ALVS - text "grand total" next to the grand-total

Subject changed to something more useful. Please do likewise in future.

HI FRIENDS,

I have a scenario like i need to print the text 'grand total' beside the grand total value in alv grid.i displayed grand total using do_sum.

thanks&regards

urmila.T

Edited by: Matt on Nov 7, 2008 1:01 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 11:14 AM

    Hi........

    You can not display any text with the subtotal...... calculated as this is calculated by standard sap itself.....

    if you want any modifications..... then use footer concept in alv...

    Thnks

    Saurabh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 11:12 AM

    Hi,,,,,, Urmila

    The subtotal is generally calculated by Standard SAP automatically......

    If you want any modifications or additions in that then you have to use Footer in your alv.....

    in which you can display your text with the total.....

    do let me know if you nedd any thing else......

    Thanks

    Saurabh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 11:14 AM

    Hi,

    Use this code....

      CLEAR wa_event.
      wa_event-name = 'TOP_OF_PAGE'.
      wa_event-form = 'TOP_OF_PAGE'.
      APPEND wa_event TO t_event.
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program     = l_repid
    *      i_callback_top_of_page = 'TOP_OF_PAGE'
          is_layout              = l_layout
          is_print               = l_print
          it_sort                = it_sort
          it_filter              = it_filter
          it_fieldcat            = t_fieldcat[]
          it_events              = t_event
          it_event_exit          = it_event_exit
        TABLES
          t_outtab               = it_vbap
        EXCEPTIONS
          program_error          = 1
          OTHERS                 = 2.
      IF sy-subrc = 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    
    ENDFORM.                    " create_alv_output
    
    *&---------------------------------------------------------------------*
    *&      Form  TOP_OF_PAGE
    *&---------------------------------------------------------------------*
    FORM top_of_page.
    
      DATA: lo_grid TYPE REF TO cl_gui_alv_grid.
    
    * get the global reference
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = lo_grid.
    
    * get the subtotal
      DATA: it_01 TYPE REF TO data.
    
      CALL METHOD lo_grid->get_subtotals
        IMPORTING
          ep_collect01 = it_01.
    
    * change the data
      FIELD-SYMBOLS: <ft_tab> TYPE ANY TABLE,
                     <fs_tab> TYPE ANY,
                     <fs_value1> TYPE ANY,
                     <fs_value2> TYPE ANY,
                     <ff_field> TYPE ANY.
      ASSIGN it_01->* TO <ft_tab>.
    
    
      LOOP AT <ft_tab> ASSIGNING <fs_tab>.
        ASSIGN COMPONENT 'VBELN' OF STRUCTURE <fs_tab> TO <ff_field>.
    <ff_field> = 'Total'.
      ENDLOOP.
    
    * Refresh the table display
      CALL METHOD lo_grid->refresh_table_display
        EXPORTING
          i_soft_refresh = 'X'.
    
    
    ENDFORM.                    " top_of_page
    

    Edited by: Sukriti Saha on Nov 7, 2008 4:44 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 07, 2008 at 11:45 AM

    TYPES : BEGIN OF TP_SAL,

    ..........

    TEXT TYPE CHAR40, "Field to store sub total text

    TEXTT TYPE CHAR40, "Field to store grand total text

    .........

    end of tp_sal.

    DATA : IG_SAL TYPE TABLE OF TP_SAL.

    DATA : WG_SAL TYPE TP_SAL.

    LOOP AT IG_SAL INTO WG_SAL.

    WG_SAL-TEXTT = 'Grand Total'.

    CONCATENATE 'SubTotal:' WG_SAL-VBELN INTO WG_SAL-TEXT.

    MODIFY IG_SAL FROM WG_SAL.

    ENDLOOP.

    CLASS LCL_EVENT_HANDLER DEFINITION.

    .................

    HANDLE_SUBTOTAL_TEXT FOR EVENT SUBTOTAL_TEXT OF CL_GUI_ALV_GRID

    IMPORTING ES_SUBTOTTXT_INFO EP_SUBTOT_LINE E_EVENT_DATA.

    ENDCLASS. "lcl_event_handler DEFINITION

    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.

    ................

    METHOD HANDLE_SUBTOTAL_TEXT.

    PERFORM SUBTOTAL_TEXT USING ES_SUBTOTTXT_INFO

    EP_SUBTOT_LINE

    E_EVENT_DATA.

    ENDMETHOD. "HANDLE_SUBTOTAL_TEXT

    FORM SUBTOTAL_TEXT USING ES_SUBTOTTXT_INFO TYPE LVC_S_STXT

    EP_SUBTOT_LINE TYPE REF TO DATA

    E_EVENT_DATA TYPE REF TO CL_ALV_EVENT_DATA.

    FIELD-SYMBOLS: <FS> TYPE ANY.

    ASSIGN E_EVENT_DATA->M_DATA->* TO <FS>.

    ENDFORM. " subtotal_text1

    MODULE STATUS_3000 OUTPUT.

    ..................

    CREATE OBJECT GR_EVENT_HANDLER.

    SET HANDLER GR_EVENT_HANDLER->HANDLE_SUBTOTAL_TEXT FOR GR_ALVGRID.

    ..........

    ENDMODULE.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.