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 Header and Footer Exporting in MS-Excel

dru_marcellana
Participant
0 Kudos

Hi guys!

I am working on an ALV report with header and footer by passing the form names to i_callback_top_of_page and

i_callback_html_end_of_list in 'REUSE_ALV_GRID_DISPLAY' FM. But,I had problems when I export the report in MS-Excel, the header and footer are not exported. Is there an alternative way so that the header and footer of the ALV Report are included when exported to MS-Excel?

Thanks!

8 REPLIES 8

Former Member
0 Kudos

Hi Andrew,

when you say header and footer, do you mean to say selection screen information or logo in header also to be displayed in excel ?

Regards,

vicky

0 Kudos

Hi Vicky,

The contents of the header and footer are just texts. I don't know why they are not exported to excel.

Thanks!

0 Kudos

Hi,

If you use the standard functionality provided by SAP to download the data in excel, the header comes into excel file.

It works for me...

Regards,Tarun

0 Kudos

Hi Tarun,

What I mean of Header and Footer is the top of page and end of page of the ALV. These two are not exportable to excel only the ALV Table is exported.

Thanks,

Andrew

0 Kudos

Hi Andrew,

Both top and end of pages are exportable to Excel.

You should do this way ..

On report output ,

<b>1</b>.u will find Local file(CTRLSHIFTf9) application

tool ,click on that.

<b>2</b>.And Select Spreadsheet and transfer the data.

You will see the top and end of pages in the Excelsheet.

Check it out.

<b>Thanks,

Venkat.O</b>

0 Kudos

Hi Venkat,

This works but my main problem is exporting not only the ALV table but also its TOP_of_page (header) and end_of_page (Footer).

Thanks,

Andrew

Former Member
0 Kudos

HI

GOOD

THIS IS A ALV HEADER AND FOOTER REPORT

Program to Test ALV Display With Header & Footer.

&----


*& Report ZRJR02 *

&----


REPORT ZRJR02 .

*Table declaration.

TABLES:ZEMP_MST,ZDEPT_MST,ZDESG_MST,ZSL_TXN.

*Varriable declaration.

TYPE-POOLS SLIS.

DATA : POS TYPE I.

DATA REPID LIKE SY-REPID.

DATA : F1 TYPE SLIS_T_FIELDCAT_ALV,

F2 TYPE SLIS_FIELDCAT_ALV,

L_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA L_POS TYPE I VALUE 1. "position of the column

DATA GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

*DATA GT_SORT TYPE SLIS_T_SORTINFO_ALV.

data: GT_EVENTS TYPE SLIS_T_EVENT,

FS_EVENTCAT LIKE LINE OF GT_EVENTs.

*Internal table declaration.

*DATA BEGIN OF IT_SORT OCCURS 5.

  • INCLUDE TYPE SLIS_SORTINFO_ALV.

*DATA END OF IT_SORT.

DATA:BEGIN OF ITAB OCCURS 0,

ZEMPNO LIKE ZEMP_MST-ZEMPNO,

ZEMPNAME LIKE ZEMP_MST-ZEMPNAME,

ZDEPTCD LIKE ZEMP_MST-ZDEPTCD,

ZDEPTNAME LIKE ZDEPT_MST-ZDEPTNAME,

ZDESGCD LIKE ZEMP_MST-ZDESGCD,

ZDESGNAME LIKE ZDESG_MST-ZDESGNAME,

END OF ITAB.

REFRESH ITAB.CLEAR ITAB.

START-OF-SELECTION.

SELECT AZEMPNO AZEMPNAME AZDEPTCD BZDEPTNAME AZDESGCD CZDESGNAME

FROM ZEMP_MST AS A

INNER JOIN ZDEPT_MST AS B

ON AZDEPTCD EQ BZDEPTCD

INNER JOIN ZDESG_MST AS C

ON AZDESGCD EQ CZDESGCD

INTO CORRESPONDING FIELDS OF TABLE ITAB.

IF SY-SUBRC <> 0.

MESSAGE E899(M3) WITH 'No records'.

ENDIF.

perform f_build_eventcat.

PERFORM LAYOUT.

END-OF-SELECTION.

&----


*& Form LAYOUT

&----


FORM LAYOUT .

PERFORM FCAT USING 'ZEMPNO' 'ITAB' '' 'Emp.No.' 'ZEMPNO' 'ZEMP_MST' ''.

PERFORM FCAT USING 'ZEMPNAME' 'ITAB' '' 'Emp. Name' 'ZEMPNAME' 'ZEMP_MST' ''.

PERFORM FCAT USING 'ZDEPTCD' 'ITAB' '' 'Dept.Code' 'ZDEPTCD' 'ZEMP_MST' ''.

PERFORM FCAT USING 'ZDEPTNAME' 'ITAB' '' 'Dept.Name' 'ZDEPTNAME' 'ZDEPT_MST' ''.

PERFORM FCAT USING 'ZDESGCD' 'ITAB' '' 'Desg.Code' 'ZDESGCD' 'ZEMP_MST' ''.

PERFORM FCAT USING 'ZDESGNAME' 'ITAB' '' 'Desg.Name' 'ZDESGNAME' 'ZDESG_MST' ''.

  • PERFORM LSORT USING 'ZEMPNO' 'IDATA' ''.

  • PERFORM LSORT USING 'ZEMPNAME' 'IDATA' ''.

  • MOVE IT_SORT[] TO GT_SORT[].

REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = REPID

IT_FIELDCAT = F1

  • IT_SORT = GT_SORT

I_SAVE = 'X'

IT_EVENTS = GT_EVENTS[]

TABLES

T_OUTTAB = ITAB.

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

&----


*& Form FCAT

&----


FORM FCAT USING P_FIELD P_TABLE P_SUM P_TEXT P_RFIELD P_RTABLE P_DISP.

ADD 1 TO POS.

F2-COL_POS = POS.

F2-FIELDNAME = P_FIELD.

F2-TABNAME = P_TABLE.

F2-SELTEXT_L = P_TEXT.

F2-REF_FIELDNAME = P_RFIELD.

F2-REF_TABNAME = P_RTABLE.

F2-DO_SUM = P_SUM.

F2-NO_OUT = P_DISP.

APPEND F2 TO F1.

CLEAR F2.

ENDFORM. " FCAT

&----


*& Form LSORT

&----


*FORM LSORT USING P_FIELD P_TABLE P_UP.

  • ADD 1 TO L_POS.

  • IT_SORT-SPOS = L_POS.

  • IT_SORT-FIELDNAME = P_FIELD.

  • IT_SORT-TABNAME = P_TABLE.

  • IT_SORT-UP = P_UP.

  • APPEND IT_SORT.

*ENDFORM. " LSORT

*----


FORM F_BUILD_EVENTCAT .

CLEAR: GT_EVENTS. REFRESH: GT_EVENTS.

CLEAR: FS_EVENTCAT.

FS_EVENTCAT-NAME = 'TOP_OF_PAGE'.

FS_EVENTCAT-FORM = 'F_REPORT_HEADER_ALV'.

APPEND FS_EVENTCAT TO GT_EVENTS.

CLEAR: FS_EVENTCAT.

FS_EVENTCAT-NAME = 'END_OF_LIST'.

FS_EVENTCAT-FORM = 'F_WRITE_SUMMARY'.

APPEND FS_EVENTCAT TO GT_EVENTS.

ENDFORM. " F_BUILD_EVENTCAT

FORM F_REPORT_HEADER_ALV.

CALL FUNCTION 'Z_YHEAD_PRINT'

EXPORTING

TITLE1 = 'XYZ Limited'

TITLE2 = 'Employee Master'

TITLE3 = 'Created on '

COLOR = 'X'

.

ENDFORM.

&----


*& Form F_WRITE_SUMMARY

&----


  • Write summary before exit

----


FORM F_WRITE_SUMMARY .

write:/ 'Welcome to XYZ Limited'.

write:/ 'This is a test program to display Report in ALV Format'.

ENDFORM.

FOR PASSING HEADER AND FOOTER VALUE TO MS-EXCEL GO THROUGH THESE LINKS

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/db22242d-0701-0010-28a2-aea...

https://unebapps01.nebraska.edu/slugo/download.nsf/31698d01fe88cac2862568c80054711d/d0a1c82d42bc6b9a...

THANKS

MRUTYUN

dru_marcellana
Participant
0 Kudos

Hi Mrutyunjaya Tripathy,

What is the contents of the custom FM? Are both Top_of_page and End_of_page exportable to MS-excel?