Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to display footer in an ALV report?

I am trying to display some information in an ALV footer, i have created subroutine for event END-OF-PAGE, now I want to display some text in footer, how to do this stuff?

Tags:
Former Member
Former Member replied

for using end-of-page event alv u must use reserve line by the starting of u r program.

and u have to supress the lines using sy-linct , and sy-linno.

go through this program u will get idea on end of page..........

tables mara.

type-pools :slis.

types : begin of tmara ,

matnr like mara-matnr,

meins like mara-meins,

ersda like mara-ersda,

color(4) type c,

sel type c,

light type c,

end of tmara.

types: begin of tmakt,

matnr like makt-matnr,

maktx like makt-maktx,

maktg like makt-maktg,

sel type c,

color(4),

end of tmakt.

data: itab type tmara occurs 0 with header line,

itab1 type tmakt occurs 0 with header line,

wa_fieldcat type slis_fieldcat_alv,

fieldcat type slis_fieldcat_alv occurs 0,

i_layout type slis_layout_alv,

wa_listheader type slis_listheader,

i_listheader type slis_listheader occurs 0,

v_events type slis_t_event ,

wa_event type slis_alv_event,

i_title_mara type lvc_title value 'FIRST LIST DISPLAYED',

i_title_makt type lvc_title value 'SECONDRY LIST DISPLAYED',

sort type slis_t_sortinfo_alv with header line,

print_cont type slis_print_alv.

*----


  • SELECTION SCREE

*----


selection-screen begin of block screen1 with frame title text-001.

selection-screen skip.

selection-screen comment /32(35) comm1.

selection-screen uline /27(35).

selection-screen skip.

select-options matnr for mara-matnr.

selection-screen skip.

selection-screen uline.

selection-screen comment /30(50) comm2.

selection-screen uline /27(40).

selection-screen skip.

select-options ersda for mara-ersda.

selection-screen skip.

selection-screen end of block screen1.

*----


  • INITIALIZATION

*----


initialization.

matnr-low = '23'.

matnr-high = '1000'.

matnr-option = 'BT'.

matnr-sign = 'I'.

append matnr.

ersda-low = '20030124'.

ersda-high = '20050302' .

append ersda.

perform fillfield.

perform filllayout.

perform build_print_params.

perform fill_sort.

perform event_call.

perform populate_event.

*----


  • SELECTION-SCREEN OUTPUT

*----


at selection-screen output.

comm1 ='SELECT MATERIAL NUMBER RANGE'.

comm2 ='SELECT MATERIAL CREATION DATE'.

*----


  • START-OF-SELECTION

*----


start-of-selection.

perform readdata.

perform popdata.

&----


*& Form READDATA

&----


  • text

----


form readdata .

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = matnr-low

importing

output = matnr-low.

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = matnr-high

importing

output = matnr-high.

select matnr

ersda

meins

from mara

into corresponding fields of

table itab

where matnr in matnr and ersda in ersda.

loop at itab.

data id_color type i value 1.

data id_colors(2) type c.

if itab-matnr < '000000000000000100'.

itab-light = '1'.

elseif itab-matnr < '000000000000000150' and itab-matnr >

'000000000000000100' .

itab-light = '2'.

else.

itab-light = '3'.

endif.

id_color = id_color + 1.

if id_color > 7.

id_color = 1.

endif.

id_colors = id_color.

concatenate 'C' id_colors '10' into itab-color.

modify itab.

clear itab.

endloop.

endform. " READDATA

----


  • Form FILLFIELD

----


form fillfield .

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-key = 'X'.

wa_fieldcat-col_pos = '1'.

wa_fieldcat-outputlen = 20.

wa_fieldcat-hotspot = 'X'.

wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

*WA_FIELDCAT-EMPHASIZE = 'C210'.

append wa_fieldcat to fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'MEINS'.

wa_fieldcat-col_pos = '2'.

*WA_FIELDCAT-EMPHASIZE = 'C510'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-seltext_m = 'UNIT'.

append wa_fieldcat to fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'ERSDA'.

wa_fieldcat-col_pos = '3'.

wa_fieldcat-outputlen = 15.

*WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

*WA_FIELDCAT-EMPHASIZE = 'C710'.

wa_fieldcat-seltext_m = 'CREAT DATE'.

append wa_fieldcat to fieldcat.

clear wa_fieldcat.

endform. "FILLFIELD

&----


  • Setup print parameters

----


form build_print_params.

print_cont-reserve_lines = '3'. "Lines reserved for footer

print_cont-no_coverpage = 'X'.

endform. " BUILD_PRINT_PARAMS

----


  • Form POPDATA

----


form popdata .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER-COMMAND'

i_callback_top_of_page = 'TOPPAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_mara

  • I_GRID_SETTINGS =

is_layout = i_layout

it_fieldcat = fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = sort[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = v_events

  • IT_EVENT_EXIT =

is_print = print_cont

tables

t_outtab = itab

exceptions

program_error = 1

others = 2

.

endform. " POPDATA

----


  • Form TOPPAGE

----


form toppage.

refresh i_listheader.

data: ld_lines type i,

ld_linesc(10) type c,

i_date(10) type c,

i_info like wa_listheader-info.

wa_listheader-typ = 'H'.

wa_listheader-info = 'MATERIAL DETAIL'.

append wa_listheader to i_listheader.

clear wa_listheader.

wa_listheader-typ = 'S'.

wa_listheader-key = 'DATE :'.

concatenate sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) into i_date.

wa_listheader-info = i_date.

append wa_listheader to i_listheader.

clear wa_listheader.

describe table itab lines ld_lines.

ld_linesc = ld_lines.

concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

into i_info separated by space.

wa_listheader-typ = 'A'.

wa_listheader-info = i_info.

append wa_listheader to i_listheader.

clear: wa_listheader , i_info.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = i_listheader

i_logo = 'ENJOYSAP_LOGO'.

endform. "TOPPAGE

----


  • Form FILLLAYOUT

----


form filllayout .

i_layout-zebra = 'X'.

i_layout-info_fieldname = 'COLOR'.

i_layout-box_fieldname = 'SEL'.

i_layout-lights_fieldname = 'LIGHT'.

i_layout-edit ='X'.

i_layout-colwidth_optimize = 'X'.

i_layout-window_titlebar = 'EXAMPLE FOR ALV GRID'.

i_layout-no_totalline = 'X'.

endform. "FILLLAYOUT

----


  • Form FILL_SORT

----


form fill_sort .

sort-down = 'X'.

sort-spos = 1.

sort-fieldname = 'MATNR'.

sort-tabname = 'MARA'.

append sort.

endform. " FILL_SORT

----


  • Form EVENT_CALL

----


form event_call .

data: i_event like v_events.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = v_events.

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. " EVENT_CALL

----


  • Form POPULATE_EVENT

----


form populate_event .

read table v_events into wa_event with key name = 'USER_COMMAND'.

if sy-subrc eq 0.

wa_event-form = 'USER_COMMAND'.

modify v_events from wa_event transporting form where name =

wa_event-name.

read table v_events with key name = slis_ev_end_of_page

into wa_event.

if sy-subrc = 0.

move 'END_OF_PAGE' to wa_event-form.

modify v_events from wa_event transporting form where name =

wa_event-name.

endif.

endif.

endform. "POPULATE_EVENT

*----


form end_of_page.

write: sy-uline(50).

skip.

write:/40 'Page:', sy-pagno .

endform.

&----


*& Form USER_COMMAND

----


form user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when '&IC1'.

case rs_selfield-fieldname.

when 'MATNR'.

read table itab with key matnr = rs_selfield-value.

if sy-subrc = 0.

perform data_retrieval_makt using rs_selfield-value.

perform build_fieldcatlog_makt.

perform filllayout_makt.

perform display_alv_makt.

clear rs_selfield.

endif.

endcase.

endcase.

endform. "user_command

----


  • Form DATA_RETRIEVAL_MAKT

----


form data_retrieval_makt using tmatnr .

select matnr

maktx

maktg

up to 100 rows

from makt

into table itab1

where spras = 'EN' and matnr = tmatnr.

loop at itab1.

data id_color type i value 1.

data id_colors(2) type c.

id_color = id_color + 1.

if id_color > 7.

id_color = 1.

endif.

id_colors = id_color.

concatenate 'C' id_colors '10' into itab1-color.

modify itab1.

clear itab1.

endloop.

endform. "DATA_RETRIEVAL_MAKT

----


  • Form FILLLAYOUT_MAKT

----


form filllayout_makt .

clear i_layout.

i_layout-zebra = 'X'.

i_layout-info_fieldname = 'COLOR'.

i_layout-box_fieldname = 'SEL'.

i_layout-edit ='X'.

i_layout-colwidth_optimize = 'X'.

i_layout-window_titlebar = 'EXAMPLE FOR ALV GRID'.

endform. " LAYOUT_MAKT

----


  • Form BUILD_FIELDCATLOG_MAKT

----


form build_fieldcatlog_makt .

refresh fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-key = 'X'.

wa_fieldcat-col_pos = '1'.

*WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

wa_fieldcat-emphasize = 'C510'.

wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

append wa_fieldcat to fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'MAKTX'.

wa_fieldcat-col_pos = '2'.

wa_fieldcat-emphasize = 'C710'.

wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

append wa_fieldcat to fieldcat.

clear wa_fieldcat.

wa_fieldcat-fieldname = 'MAKTG'.

wa_fieldcat-col_pos = '3'.

wa_fieldcat-emphasize = 'C210'.

wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

append wa_fieldcat to fieldcat.

clear wa_fieldcat.

endform. " BUILD_FIELDCATLOG_MAKT

----


  • Form DISPLAY_ALV_MAKT

----


form top-of-page.

refresh i_listheader.

data: ld_lines type i,

ld_linesc(10) type c,

i_date(10) type c,

i_info like wa_listheader-info.

wa_listheader-typ = 'H'.

wa_listheader-info = 'MATERIAL DESCRIPTION FOR SELECTED NUMBER'.

append wa_listheader to i_listheader.

clear wa_listheader.

wa_listheader-typ = 'S'.

wa_listheader-key = 'DATE :'.

concatenate sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) into i_date.

wa_listheader-info = i_date.

append wa_listheader to i_listheader.

clear wa_listheader.

describe table itab1 lines ld_lines.

ld_linesc = ld_lines.

concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

into i_info separated by space.

wa_listheader-typ = 'A'.

wa_listheader-info = i_info.

append wa_listheader to i_listheader.

clear: wa_listheader , i_info.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = i_listheader

i_logo = 'ENJOYSAP_LOGO'.

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

endform. "TOP-OF-PAGE

&----


*& Form DISPLAY_ALV_MAKT

&----


  • text

----


form display_alv_makt .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

i_callback_top_of_page = 'TOP-OF-PAGE'

i_grid_title = i_title_makt

is_layout = i_layout

it_fieldcat = fieldcat

tables

t_outtab = itab1

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. " DISPLAY_ALV_MAKT

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question