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: 

alv grid end_of_page

Former Member
0 Kudos

I use this code for end of list. I went it in end of page. I replaced end_of_list by end_of_page but its not ok.

Data: it_events type slis_t_event.

Data: w_events type slis_alv_event.

w_events-name = 'END_OF_LIST'.

w_events-form = 'SUB_END_LIST'.

append w_events to it_events.

Form sub_end_list.

write: sy-uname,sy-pagno.

endform.

What can i do for end of page (i use function REUSE_ALV_GRID_DISPLAY)?

Thanks a lot

7 REPLIES 7

Former Member
0 Kudos

Check to see if you reserve the line for the footer in the print parameter. Here are the steps to add the END_OF_PAGE to the alv event. You will need a subroutine to fill up the print parameter:

Data: gd_prntparams type slis_print_alv.

*&------------------------------------------------------------------*
*&      Form  BUILD_PRINT_PARAMS
*&------------------------------------------------------------------*
*       Setup print parameters
*-------------------------------------------------------------------*
form build_print_params.
  gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
  gd_prntparams-no_coverpage = 'X'.
endform.  

Here are the steps to add event to the ALV FM:

<b>Step 1. Add data declaration for events and print parameters

Step 2. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include parameter 'it_events' and 'is_print'

Step 3. Add code to setup events table and print parameters

Step 4. Create event FORM(s), which are executed when event is triggered</b>

Also, the end of page event is not visible on screen. Only visible on printout.

If you are using OO, take a look at demo program BCALV_TEST_GRID_EVENTS which has all the common events.

Hope this help. Points are always welcome!

Regards,

Minami

Former Member
0 Kudos

Hi,

below is the sample code, where i have used REUSE_ALV_GRID_DISPLAY and end_of_page event.

check if this is helpful.

start-of-selection.

    • setup the events

perform f_setup_events.

    • print alv

perform f_alv_display.

&----


*& Form setup_events

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f_setup_events.

data : li_events type slis_alv_event.

check i_events[] is initial.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = i_events.

    • top of page-- header

loop at i_events into li_events where name = slis_ev_top_of_page.

li_events-form = 'F_TOP_OF_PAGE'.

modify i_events from li_events.

endloop.

loop at i_events into li_events where name = slis_ev_end_of_list.

li_events-form = 'F_END_OF_PAGE'.

modify i_events from li_events.

endloop.

ENDFORM. " setup_events

&----


*& Form f_end_of_page

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form f_end_of_page.

DATA: li_footer TYPE slis_listheader,

lv_footer(250) type c,

lv_lines type n.

clear : li_footer, lv_footer.

describe table i_zhbltresult lines lv_lines.

li_footer-typ = 'S' .

li_footer-key = ' '.

concatenate 'Total Records Selected for deletion : ' lv_lines into

lv_footer.

li_footer-info = lv_footer.

APPEND li_footer to i_footer.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_footer

i_end_of_list_grid = c_x.

&----


*& Form f_top_of_page

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form f_top_of_page.

data : li_header type slis_listheader,

lv_heading(250) type c,

lv_lines(5) type n,

lv_page(3) type n,

lv_pagno type char3.

    • Populate the title.

refresh i_header.

clear li_header.

li_header-typ = 'H'.

li_header-key = ' '.

li_header-info = sy-title.

append li_header to i_header.

    • Populate report

clear : li_header, lv_heading.

li_header-typ = 'S'.

li_header-key = 'Report : '.

li_header-info = sy-repid.

append li_header to i_header.

    • Populate User ID.

clear : li_header, lv_heading.

li_header-typ = 'S'.

li_header-key = 'User ID : '.

li_header-info = sy-uname.

append li_header to i_header.

    • fm that will print the header

call function 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[].

endform. " f_top_of_page

&----


*& Form alv_display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form f_alv_display.

data l_repid like sy-repid.

l_repid = sy-repid.

    • build the alv catalog

perform f_build_fieldcat using :

1 1 'SERIAL_NO' 'S/N' 'i_disp',

1 2 'PERNR' 'Staff no' 'i_disp',

1 3 'BEGDA' 'Begin Date' 'i_disp',

1 4 'ENDDA' 'End Date' 'i_disp',

1 5 'SEQNR' 'Seq No' 'i_disp',

1 6 'ZUSERID' 'Prog Run By' 'i_disp',

1 7 'ZPDATE' 'Prog Run Date' 'i_disp',

1 8 'ZPTIME' 'Prog Run Time' 'i_disp',

1 9 'UNAME' 'Last Chg By' 'i_disp',

1 10 'AEDTM' 'Last Chg Date' 'i_disp'.

call function 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = l_repid

i_callback_top_of_page = 'TOP_OF_PAGE'

i_structure_name = 'i_disp'

it_fieldcat = i_fieldcat

it_events = i_events

TABLES

t_outtab = i_disp.

endform. " alv_display

Regards,

Nidhya

0 Kudos

code for Nidhya is ok but the header is editing lot of times (1 and 2 and 4 and 8 etc..) not one time. What c_x?

I went insert number page in top_of_page. What can i do?

Former Member
0 Kudos
This is for LIST DISPLAY.


REPORT  ZTEST_ALV_CHECK        .
 
 
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
      IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      L_LAYOUT type slis_layout_alv,
      x_events type slis_alv_event,
      it_events type SLIS_T_EVENT.
 
DATA: BEGIN OF ITAB OCCURS 0,
      VBELN LIKE VBAK-VBELN,
      POSNR LIKE VBAP-POSNR,
     END OF ITAB.
 
SELECT VBELN
       POSNR
       FROM VBAP
       UP TO 20 ROWS
       INTO TABLE ITAB.
 
 
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
 
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
 
 
  x_events-NAME = SLIS_EV_END_OF_PAGE.
  x_events-FORM = 'END_OF_PAGE'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
  x_events-NAME = SLIS_EV_TOP_OF_PAGE.
  x_events-FORM = 'TOP_OF_PAGE'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
 
  x_events-NAME = slis_ev_end_of_list.
  x_events-FORM = 'END_OF_LIST'.
  APPEND x_events  TO iT_EVENTS.
  CLEAR x_events .
 
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
    I_CALLBACK_PROGRAM       = SY-REPID
    IS_LAYOUT                = L_LAYOUT
    IT_FIELDCAT              = IT_FIELDCAT
    it_events                = it_events
  TABLES
    T_OUTTAB                 = ITAB
  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.
 
FORM TOP_OF_PAGE.
* BREAK-POINT.
  WRITE: / 'TOP_OF_PAGE'.
ENDFORM.
FORM END_OF_LIST.
* BREAK-POINT.
"here you can use this for footer
  WRITE: / 'FOR FOOTER'.
ENDFORM.
FORM END_OF_PAGE.
* BREAK-POINT.
  WRITE: / 'END_OF_PAGE'.
ENDFORM.

Former Member
0 Kudos

0 Kudos

the code of Chandrasekhar is ok too but the text is disappeared if i edite list

Former Member
0 Kudos

This message was moderated.