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: 

How to get a Footer text in alv grid?

Former Member
0 Kudos

Hi,

am using RESUE_ALV_COMMENTARy_write... it is getting only on top of page..

suggest me to get Footer text in ALV GRiD.

Regards,

sodanapalli

Moderator message: please do more research before asking, all points removed (both replies were copy/pasted anyway)

Edited by: Thomas Zloch on May 19, 2011 5:41 PM

2 REPLIES 2

praveen_reddy2
Active Participant
0 Kudos

Hello,


* Calling the top of page method
    CALL METHOD SET_TOP_OF_PAGE
      CHANGING
        CO_ALV = O_ALV.

* Calling the End of page method
    CALL METHOD SET_END_OF_PAGE
      CHANGING
        CO_ALV = O_ALV.

*    ************************************************************************
* Displaying the ALV
* Here we will call the DISPLAY method to get the output on the screen
************************************************************************
    O_ALV->DISPLAY( ).
  ENDMETHOD.                    "generate_output

*  ************************************************************************
*    In this area we will implement the methods which are defined in
*    the class definition
************************************************************************
* Setting Default PF-Status
  METHOD SET_PF_STATUS.
    DATA: LO_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS_LIST.
* Default functions
    LO_FUNCTIONS = CO_ALV->GET_FUNCTIONS( ).
    LO_FUNCTIONS->SET_DEFAULT( ABAP_TRUE ).
  ENDMETHOD.                    "set_pf_status

* Setting Top_of_page
  METHOD SET_TOP_OF_PAGE.
    DATA: LO_HEADER TYPE REF TO CL_SALV_FORM_LAYOUT_GRID,
          LO_H_LABEL TYPE REF TO CL_SALV_FORM_LABEL,
          LO_H_FLOW  TYPE REF TO CL_SALV_FORM_LAYOUT_FLOW.

*    * Header object
    CREATE OBJECT LO_HEADER.

*    *----------------------------------------------------------------------*
* To create a Label or Flow we have to specify the target
* row and column number where we need to set up the output
* text.
*----------------------------------------------------------------------*
* Information in Bold
    LO_H_LABEL = LO_HEADER->CREATE_LABEL( ROW = 1 COLUMN = 1 ).
    LO_H_LABEL->SET_TEXT('Header of the ALV Output in Bold').

* Information in tabular format
    LO_H_FLOW = LO_HEADER->CREATE_FLOW( ROW = 2 COLUMN = 1 ).
    LO_H_FLOW->CREATE_TEXT( TEXT = 'This is text of flow in Header' ).

    LO_H_FLOW = LO_HEADER->CREATE_FLOW( ROW = 3 COLUMN = 1 ).
    LO_H_FLOW->CREATE_TEXT( TEXT = 'Date of List Generation' ).

    LO_H_FLOW = LO_HEADER->CREATE_FLOW( ROW = 3 COLUMN = 2 ).
    LO_H_FLOW->CREATE_TEXT( TEXT = sy-datum ).

* Set the top of list using the header for Online
    CO_ALV->SET_TOP_OF_LIST( LO_HEADER ).
* Set the top of list using the header for Print
    CO_ALV->SET_TOP_OF_LIST_PRINT( LO_HEADER ).

  ENDMETHOD.                    "set_top_of_page

* Setting End_Of_page
  METHOD SET_END_OF_PAGE.
    DATA: LO_FOOTER  TYPE REF TO CL_SALV_FORM_LAYOUT_GRID,
          LO_F_LABEL TYPE REF TO CL_SALV_FORM_LABEL,
          LO_F_FLOW  TYPE REF TO CL_SALV_FORM_LAYOUT_FLOW.
* Footer Object
    CREATE OBJECT LO_FOOTER.

* Information in Bold
    LO_F_LABEL = LO_FOOTER->CREATE_LABEL( ROW = 1 COLUMN = 1 ).
    LO_F_LABEL->SET_TEXT('Footer of the ALV in Bold').

* Tabular Information
    LO_F_FLOW = LO_FOOTER->CREATE_FLOW( ROW = 2 COLUMN = 1 ).
    LO_F_FLOW->CREATE_TEXT( TEXT = 'This is text of flow in footer' ).

* Set the end of list using the header for Online
    CO_ALV->SET_END_OF_LIST( LO_FOOTER ).
* Set the End of list using the header for Print
    CO_ALV->SET_END_OF_LIST_PRINT( LO_FOOTER ).
  ENDMETHOD.                    "set_end_of_page

ENDCLASS.                    "lcl_report IMPLEMENTATION

*----------------------------------------------------------------------*
START-OF-SELECTION.
*----------------------------------------------------------------------*
  DATA: LO_REPORT TYPE REF TO LCL_REPORT.

  CREATE OBJECT LO_REPORT.

  LO_REPORT->GETDATA( ).
  LO_REPORT->GENERATE_OUTPUT( ).

this is using oops alv

Edited by: praveenreddys on May 19, 2011 5:31 PM

Former Member
0 Kudos

Step1: Populate the ALV event table with 'END_OF_LIST' event

Step2: Populate the footer text in to an internal table which is of type

slis_t_listheader.

Step3: Create a subroutine with name 'END_OF_LIST' and with in this form we have to call the function module u2018REUSE_ALV_COMMENTARY_WRITEu2019.

Step4: Now call the function module REUSE_ALV_GRID_DISPLAYu2019 to display the ALV report. Whenever u2018END_OF_LIST' event is get fired it executes the subroutine END_OF_LIST and displays the text into the footer of the ALV GRID.

Code:

&----


*& Report Z_TEST_ALV

*&

&----


*&

*&

&----


REPORT z_test_alv.

TYPE-POOLS: slis.

DATA: i_mara TYPE STANDARD TABLE OF mara INITIAL SIZE 0,

i_events TYPE slis_t_event,

i_end_of_page TYPE slis_t_listheader,

w_events TYPE slis_alv_event,

v_repid LIKE sy-repid.

START-OF-SELECTION.

SELECT * FROM

mara INTO TABLE i_mara

UP TO 100 ROWS.

CHECK sy-subrc = 0.

PERFORM populate_alv_event.

PERFORM comment_build USING i_end_of_page[].

PERFORM display_grid.

&----


*& Form POPULATE_ALV_EVENT

&----


FORM populate_alv_event .

  • Populate event table

w_events-name = 'END_OF_LIST'.

w_events-form = 'END_OF_LIST'.

APPEND w_events TO i_events.

ENDFORM. " POPULATE_ALV_EVENT

&----


*& Form COMMENT_BUILD

&----


FORM comment_build USING p_i_end_of_page TYPE slis_t_listheader.

DATA: ls_line TYPE slis_listheader.

REFRESH p_i_end_of_page.

CLEAR ls_line.

ls_line-typ = 'H'.

ls_line-info = 'This is end of list'(001).

APPEND ls_line TO p_i_end_of_page.

ENDFORM. " COMMENT_BUILD

&----


*& Form end_of_list

&----


FORM end_of_list.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_end_of_page.

ENDFORM. "end_of_list

&----


*& Form DISPLAY_GRID

&----


FORM display_grid .

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_structure_name = 'MARA'

it_events = i_events

TABLES

it_outtab = i_mara

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

ENDFORM. " DISPLAY_GRID

Check the output where footer will be displayed as 'THIS IS END OF LIST'