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 use END_OF_PAGE event when using 'REUSE_ALV_GRID_DISPLAY'

Former Member
0 Kudos
363

Hi Experts,

I am using 'REUSE_ALV_GRID_DISPLAY' function module. I want to write something in END_OF_PAGE event. I have created event internal table with Event name & form. This table contains TOP_OF_PAGE & END_OF_PAGE events & formname. TOP_OF_PAGE event is working fine. But END_OF_PAGE is not working. The code is like:-

FORM get_event .

DATA: lst_event TYPE slis_alv_event.

lst_event-name = 'TOP_OF_PAGE'.

lst_event-form = 'TOP_OF_PAGE'.

APPEND lst_event TO gi_events.

CLEAR lst_event.

lst_event-name = 'END_OF_PAGE'.

lst_event-form = 'END_OF_PAGE'.

APPEND lst_event TO gi_events.

ENDFORM. " get_event

form display.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_grid_title = 'Material Details'

is_layout = gs_layout

it_fieldcat = gi_fcat

it_events = gi_events

TABLES

t_outtab = gi_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

endform.

FORM top_of_page.

DATA : ta_header TYPE slis_t_listheader,

wa_header TYPE slis_listheader.

CLEAR : wa_header, ta_header[], ta_header.

wa_header-typ = 'H'. "Header

wa_header-info = 'REPORT LIST : ALV Testing'.

APPEND wa_header TO ta_header.

CLEAR wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = ta_header

i_logo = 'ENJOYSAP_LOGO'.

ENDFORM. "top_of_page

FORM end_of_page.

DATA : ta_header TYPE slis_t_listheader,

wa_header TYPE slis_listheader.

CLEAR : wa_header, ta_header[], ta_header.

wa_header-typ = 'H'. "Header

wa_header-info = 'End of Report'.

APPEND wa_header TO ta_header.

CLEAR wa_header.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = ta_header.

ENDFORM. "end_of_page

Also how can i find the details list of logos.

Thanx in advance.

12 REPLIES 12

Former Member
0 Kudos
166

Hi,
Perform following steps if you are using ALV FM.

1. Build the events table

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = RT_EVENTS.

IF SY-SUBRC <> 0.
ENDIF.

READ TABLE RT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE ALV_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO RT_EVENTS.
ENDIF.


2. Write a subroutine END_OF_PAGE

FORM END_OF_PAGE. "#EC CALLED
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = SPACE
IT_LIST_COMMENTARY = ALV_LIST_TOP_OF_PAGE.

IF SY-SUBRC NE 0.
ENDIF.

ENDFORM. 


3. Build the comments you want to write at the End of Page.

4. Now call the ALV FM

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = ALV_FCAT[]
I_SAVE = 'X'
IT_EVENTS = ALV_EVENTS[]
TABLES
T_OUTTAB = ITAB1
EXCEPTIONS
PROGRAM_ERROR = 0
OTHERS = 0.


Hope it helps.
Vasanth

0 Kudos
166

Dear Vasanth,

The same thing i m doing but not working. You can see my code. Is there any other parameter is to be passed to 'REUSE_ALV_GRID_DISPLAY' or 'REUSE_ALV_COMMENTARY_WRITE'?

regards,

0 Kudos
166

Hello,

CHanghe this part:


data: lv_repid like sy_repid. " Check here
lv_repid eq sy_repid. " Check here
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = lv_repid   " Check here
i_grid_title = 'Material Details'
is_layout = gs_layout
it_fieldcat = gi_fcat
it_events = gi_events
TABLES
t_outtab = gi_final
EXCEPTIONS
program_error = 1
OTHERS = 2.
endform.

0 Kudos
166

i have checked. it's not working.

0 Kudos
166

I have tried and it worked.

Here I should mention the main three points.

1. Mention the LINE-COUNT at report line.

as REPORT ZZZZ_ALV

NO STANDARD PAGE HEADING LINE-SIZE 255

LINE-COUNT 65.

2. Instead of using END_OF_PAGE event, use END_OF_LIST event.

Appended in the EVENT table and calling the dynamic PERFORM.

READ TABLE t_events

WITH KEY name = slis_ev_end_of_list INTO l_event

BINARY SEARCH.

IF sy-subrc = 0.

l_event-form = 'END_OF_LIST'.

APPEND l_event TO t_events.

ENDIF.

3. Mention the Parameter of Commentary write FM.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = t_header

i_end_of_list_grid = 'X'.

Former Member
0 Kudos
166

Hello,

Please check the below :-



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,
Deepu.K

0 Kudos
166

Dear Deepu,

The same thing i m doing but not working. You can see my code. Is there any other parameter is to be passed to 'REUSE_ALV_GRID_DISPLAY' or 'REUSE_ALV_COMMENTARY_WRITE'?

regards,

0 Kudos
166

Hi,

try to use end-of-list event for displaying those contents.i think it is not possible use end-of-page event contents.

<b>reward if helpful.</b>

rgds,

bharat.

Former Member
0 Kudos
166

Hi Sachin,

For displaying end of page , you need to specify line-count in the report statement like

REPORT ZREPNAME LINE-COUNT 65.

and it should work.

Hope that helps.

Regards,

Jayant

Former Member
0 Kudos
166

Hi Sachin,

As Vinaykumar says the event END-OF-PAGE triggers only when we give the print ( or Execute in back ground where the spool is generated ).

So, if you want to display the Footer ( No of records processed ) you can display it on the TOP-OF-PAGE of the next page.

The disadvantage in this is when the user wants to see it on screen first and then give the print, the user sees the grid correctly. but when he gives the print the footer is printed on the top of page of the next page.

The other option is:

Step 1 : Limit the no of items printed on each page ( consider 10 ).

Step 2 : In the item table add one more field page type sy-pagno. This field has to be incremented for every 10 items.

Step 3 : Populate the sort table with this new field so that page trigger happens affter every 10 items.

l_sort-fieldname = 'PAGE'.

l_sort-group = '*'.

Step 4 : Use the even after_line_output to get the current record that is being printed.

form after_line_output using fp_rs_lineinfo type slis_lineinfo.

fp_rs_lineinfo-tabindex indicates the current record number.

Step 5 : Check if the next record number has diffent value in the field page by reading the item table.

Step 6 : If different print end of page. Ie call the perform end_of_page.

form after_line_output using fp_rs_lineinfo type slis_lineinfo.

Local data declaration

data: l_wa_item type ty_item, "Item details

l_v_tabix type sy-tabix. "Index cnt

l_v_tabix = fp_rs_lineinfo-tabindex + 1.

read table i_item into l_wa_item index l_v_tabix.

if sy-subrc is initial.

if l_wa_item-page ne v_page.

uline.

perform end_of_page.

v_page = l_wa_item-page.

endif.

endif.

endform. "AFTER_LINE_OUTPUT

Please reward if usefull.

Regards,

Satish.

Former Member
0 Kudos
166

DATA: TOP_EVENT TYPE SLIS_ALV_EVENT,

ELIST_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 4

IMPORTING

ET_EVENTS = I_EVENTS.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO TOP_EVENT.

IF SY-SUBRC = 0.

MOVE GC_FORMNAME_TOP_OF_PAGE TO TOP_EVENT-FORM.

APPEND TOP_EVENT TO I_EVENTS.

ENDIF.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_LIST INTO ELIST_EVENT.

IF SY-SUBRC = 0.

MOVE GC_FORMNAME_END_OF_LIST TO ELIST_EVENT-FORM.

APPEND ELIST_EVENT TO I_EVENTS.

ENDIF.

TOP-OF-PAGE.

....

...

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = I_LIST_TOP_OF_PAGE

I_ALV_FORM = 'X'.

REFRESH I_LIST_TOP_OF_PAGE.

..........

END-OF-PAGE.

same as in top of page

.........

Former Member
0 Kudos
166

Hi,

T0 Find the list of logos

go to SE78

Regards,

V.Balaji

Reward if Usefull...