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: 

Footer in ALV

Former Member
0 Kudos
78

Hi Experts,

Is it possbile to write Footer in ALV Report, can any one send piece of code.

Thanks in advance.....

..Rams

1 ACCEPTED SOLUTION

Former Member
0 Kudos
55

HI,

see this program,

REPORT ZBHALV_LIST1.

TABLES:MARA.

SELECT-OPTIONS: MATNR FOR MARA-MATNR.

DATA:BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

MTART LIKE MARA-MTART,

MBRSH LIKE MARA-MBRSH,

END OF ITAB.

SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR

IN MATNR.

TYPE-POOLS SLIS.

DATA:FCAT TYPE slis_t_fieldcat_alv.

DATA:LAYOUT TYPE slis_layout_alv.

DATA:EVE TYPE slis_t_event WITH HEADER LINE.

DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.

DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.

SORT-UP = 'X'.

SORT-SPOS = 1.

SORT-FIELDNAME = 'ERSDA'.

SORT-tabname = 'MARA'.

APPEND SORT.

SORT-SPOS = 2.

SORT-FIELDNAME = 'MTART'.

SORT-tabname = 'MARA'.

APPEND SORT.

EVE-NAME = 'TOP_OF_PAGE'.

EVE-FORM = 'TOPOFPAGE'.

APPEND EVE.

EVE-NAME = 'TOP_OF_LIST'.

EVE-FORM = 'TOPOFLIST'.

APPEND EVE.

EVE-NAME = 'END_OF_LIST'.

EVE-FORM = 'ENDOFLIST'.

APPEND EVE.

LAYOUT-ZEBRA = 'X'.

LAYOUT-no_hline = 'X'.

LAYOUT-NO_VLINE = 'X'.

LAYOUT-window_titlebar = 'MATERIAL DETAILS'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = SY-REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FCAT

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_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 =

  • I_STRUCTURE_NAME =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = SORT[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = EVE[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 5

  • I_SCREEN_START_LINE = 5

  • I_SCREEN_END_COLUMN = 120

  • I_SCREEN_END_LINE = 25

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

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 TOPOFPAGE.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'MATERIALS'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[]

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

ENDFORM.

FORM TOPOFLIST.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'MATERIALS-LISTTOP'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[]

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

ENDFORM.

<b>FORM ENDOFLIST.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'MATERIALS-LISTEND'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[]

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

ENDFORM.</b>

<b>reward if helpful</b>

rgds,

bharat.

4 REPLIES 4

Former Member
0 Kudos
56

HI,

see this program,

REPORT ZBHALV_LIST1.

TABLES:MARA.

SELECT-OPTIONS: MATNR FOR MARA-MATNR.

DATA:BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

MTART LIKE MARA-MTART,

MBRSH LIKE MARA-MBRSH,

END OF ITAB.

SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR

IN MATNR.

TYPE-POOLS SLIS.

DATA:FCAT TYPE slis_t_fieldcat_alv.

DATA:LAYOUT TYPE slis_layout_alv.

DATA:EVE TYPE slis_t_event WITH HEADER LINE.

DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.

DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.

SORT-UP = 'X'.

SORT-SPOS = 1.

SORT-FIELDNAME = 'ERSDA'.

SORT-tabname = 'MARA'.

APPEND SORT.

SORT-SPOS = 2.

SORT-FIELDNAME = 'MTART'.

SORT-tabname = 'MARA'.

APPEND SORT.

EVE-NAME = 'TOP_OF_PAGE'.

EVE-FORM = 'TOPOFPAGE'.

APPEND EVE.

EVE-NAME = 'TOP_OF_LIST'.

EVE-FORM = 'TOPOFLIST'.

APPEND EVE.

EVE-NAME = 'END_OF_LIST'.

EVE-FORM = 'ENDOFLIST'.

APPEND EVE.

LAYOUT-ZEBRA = 'X'.

LAYOUT-no_hline = 'X'.

LAYOUT-NO_VLINE = 'X'.

LAYOUT-window_titlebar = 'MATERIAL DETAILS'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = SY-REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FCAT

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_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 =

  • I_STRUCTURE_NAME =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = SORT[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = EVE[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 5

  • I_SCREEN_START_LINE = 5

  • I_SCREEN_END_COLUMN = 120

  • I_SCREEN_END_LINE = 25

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

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 TOPOFPAGE.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'MATERIALS'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[]

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

ENDFORM.

FORM TOPOFLIST.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'MATERIALS-LISTTOP'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[]

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

ENDFORM.

<b>FORM ENDOFLIST.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'MATERIALS-LISTEND'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[]

  • I_LOGO =

  • I_END_OF_LIST_GRID =

.

ENDFORM.</b>

<b>reward if helpful</b>

rgds,

bharat.

former_member194669
Active Contributor
0 Kudos
55

Hi,

Check this. I find one of the SAP sites


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 A~ZEMPNO A~ZEMPNAME A~ZDEPTCD B~ZDEPTNAME A~ZDESGCD C~ZDESGNAME
       FROM ZEMP_MST AS A
         INNER JOIN ZDEPT_MST AS B
           ON A~ZDEPTCD EQ B~ZDEPTCD
         INNER JOIN ZDESG_MST AS C
           ON A~ZDESGCD EQ C~ZDESGCD
       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.

aRs

varma_narayana
Active Contributor
0 Kudos
55

Hii

It is Same as How you generate the Header using TOP_OF_PAGE event.

use the END_OF_PAGE event for footer..

Use FM - 'REUSE_ALV_COMMENTARY_WRITE'.

FORM END_OF_PAGE.

DATA: WA_HEADER TYPE SLIS_LISTHEADER.

REFRESH: GT_LIST_END_OF_PAGE.

H = HEADER LARGE FONT, S = STANDARD FONT, A = ITALICS

WA_HEADER-TYP = 'H'. WA_HEADER-INFO = 'TEST REPORT'.

APPEND WA_HEADER TO GT_LIST_END_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

  • I_LOGO = 'LOGO'

IT_LIST_COMMENTARY = GT_LIST_END_OF_PAGE.

ENDFORM.

<b>Reward if Helpful.</b>

Former Member
0 Kudos
55

Hi,

Yes, u can create a footer in ALV display by using END_OF_PAGE event.

Try with the following example coding from ABAPDOCU.

 REPORT demo_page_header_footer NO STANDARD PAGE HEADING 
                               LINE-COUNT 0(1). 

PARAMETER p_carrid TYPE sflight-carrid. 

DATA: sflight_tab TYPE TABLE OF sflight, 
      sflight_wa  LIKE LINE  OF sflight_tab. 

DATA lines TYPE i. 

TOP-OF-PAGE. 
  WRITE: / sflight_wa-carrid, sflight_wa-connid. 
  ULINE. 

END-OF-PAGE. 
  ULINE. 

START-OF-SELECTION. 

  SELECT carrid connid fldate 
         FROM sflight 
         INTO CORRESPONDING FIELDS OF TABLE sflight_tab 
         WHERE carrid = p_carrid 
         ORDER BY carrid connid. 

  LOOP AT sflight_tab INTO sflight_wa. 
    AT NEW connid. 
      SELECT COUNT( DISTINCT fldate ) 
             FROM sflight 
             INTO lines 
             WHERE carrid = sflight_wa-carrid AND 
                   connid = sflight_wa-connid. 
      lines = lines + 3. 
      NEW-PAGE LINE-COUNT lines. 
    ENDAT. 
    WRITE / sflight_wa-fldate. 
  ENDLOOP. 

Try and reward if found useful.

Friendly Note: Many have answered your questions, so please reward and close the thread.

Regards,

Sathya.