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 print footer in ALV report

anujawani2426
Active Participant
0 Kudos

Hello Everyone,

I have seen so many questions were raised on how to print footer in ALV. I checked all answers and did code but still it is not working. Hence I raised this question again. I want to print page number on each page using end_of_page.

Please note it's end_of_page not end_of_list. Because end_of_list is working for me and using that i can not print page number.

Here is my code.

TABLES: mara.
TYPE-POOLS:slis.
TYPES:
BEGIN OF ty_mara,
matnr TYPE matnr,
ersda TYPE ersda,
ernam TYPE ernam,
mtart TYPE mtart,
mbrsh TYPE mbrsh,
END OF ty_mara.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_mara TYPE TABLE OF ty_mara,
it_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
gd_print TYPE slis_print_alv1,
wa_event TYPE slis_alv_event,
gt_events TYPE slis_t_event.
SELECT-OPTIONS: matnr FOR mara-matnr.
INITIALIZATION.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_events[]
* EXCEPTIONS
* LIST_TYPE_WRONG = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
READ TABLE gt_events WITH KEY name = 'END_OF_PAGE' INTO wa_event.
IF sy-subrc = 0.
MOVE 'END_OF_PAGE' TO wa_event-form.
APPEND wa_event TO gt_events.
ENDIF.
gd_print-reserve_lines = '3'. "Lines reserved for footer
gd_print-no_coverpage = 'X'.
START-OF-SELECTION.
SELECT
matnr
ersda
ernam
mtart
mbrsh
FROM mara
INTO TABLE it_mara WHERE matnr IN matnr.
wa_fieldcat-fieldname = 'MATNR'. " Fieldname in the data table
wa_fieldcat-seltext_m = 'Material NO'. " Column description in the output
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-seltext_m = 'Created On'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-seltext_m = 'Created By'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-seltext_m = 'Material Type'.
APPEND wa_fieldcat TO it_fieldcat.


  wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-seltext_m = 'Industial Sector'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = 'X'
i_bypassing_buffer = 'X'
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'TOP'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'X'
* I_SAVE = ' '
* IS_VARIANT =
it_events = gt_events[]
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* O_PREVIOUS_SRAL_HANDLER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_mara
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
FORM top.
wa_header-typ = 'S'.
wa_header-info = 'Material Data'.
wa_header-key = 'Material Data'.
APPEND wa_header TO it_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header
* I_LOGO =
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
ENDFORM.
FORM end_of_page.
WRITE: sy-uline(50).
SKIP.
WRITE:/40 'Page:', sy-pagno .
ENDFORM.
19 REPLIES 19

Sandra_Rossi
Active Contributor

You just forgot to pass the parameter IS_PRINT.

anujawani2426
Active Participant
0 Kudos

Hi Sandra,

What needs to pass to IS_PRINT ?

Regards,

Anuja Kawadiwale

venkateswaran_k
Active Contributor
0 Kudos

You have already set the following variables

  gd_print-reserve_lines = '3'. "Lines reserved for footer
  gd_print-no_coverpage = 'X'.

As Sandra said, Just you need to pass in function call - FUNCTION 'REUSE_ALV_GRID_DISPLAY'

 IS_PRINT = gd_print    <=== 

anujawani2426
Active Participant
0 Kudos

I tried but still not working

venkateswaran_k
Active Contributor
0 Kudos

Check with the Upper Case. in both place ( at Form defenition ) and passing the value in parameter

END_OF_PAGE

You have defined form as lower case 'end_of_page'. Use the same case in both place

  READ TABLE gt_events WITH KEY name = 'END_OF_PAGE' INTO wa_event.
IF sy-subrc = 0.
MOVE 'END_OF_PAGE' TO wa_event-form.
APPEND wa_event TO gt_events.
ENDIF.

anujawani2426
Active Participant
0 Kudos

Hi venkateswaran.k ,

I changed it. Still not working.

Sandra_Rossi
Active Contributor
0 Kudos

When I use your code with the fix I mentioned, and that I click the button Print to generate the spool, it works fine for me.

Maybe you want to do something else?

anujawani2426
Active Participant
0 Kudos

Hi Sandra,

I want to print footer in my report. That is not working.

venkateswaran_k
Active Contributor
0 Kudos

Can't find out what is missing - since sandra said it works.

may be try as below

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header
* I_LOGO =
I_END_OF_LIST_GRID = 'X' <===== pass X here
* I_ALV_FORM =

Sandra_Rossi
Active Contributor
0 Kudos

If you run your program and you don't click Print button, of course the spool request will not be generated. Could you explain what you exactly do?

Sandra_Rossi
Active Contributor
0 Kudos

When I run your program and I print the ALV, this is what I get. Sorry that it doesn't work for you. Bye.

anujawani2426
Active Participant
0 Kudos

Hi venkateswaran.k,

As Sandra said, spool is generated. Yes it is generated. But I want footer on my report. That is my issue only.

Even though I pass 'X' to I_END_OF_LIST_GRID not working.

anujawani2426
Active Participant
0 Kudos

Hi,

It's not working for me.

venkateswaran_k
Active Contributor
0 Kudos

are you using any variant ? in the layout

anujawani2426
Active Participant
0 Kudos

I am not using any variant.

Sandra_Rossi
Active Contributor

Q1. What you show seems to be a Windows print preview, maybe PDF. Is it?

Q2. It seems to be truncated, there's no horizontal line at the top and at the bottom. Could you check in the spool request if the top/bottom borders are there, and maybe more data? Maybe a printer or paper format definition issue in SPAD.

Q3. By the way, did you add this line to your program?

 IS_PRINT = gd_print

anujawani2426
Active Participant
0 Kudos

Hi,

Yes, I think it is a paper format definition issue. I tried to execute the demo program and generated the spool but footer is not showing in that report also for me.

I have added that line also.

Thanks

Rajasekhar_Dina
Participant
0 Kudos

WRITE:/ sy-uline(50).

SKIP.

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

You missed the slash for the uline.

0 Kudos

Or you can use the following:

WRITE AT /(sy-linsz) SY-PAGNO CENTERED.