Application Development and Automation 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: 
Read only

alv

Former Member
0 Likes
1,287

In alv is there any possibilyt of footer..?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,261

Yes you can. It is possible with the alv list display. Hence you can have the header and footer too.

Regards,

Sankar.

Yes you can. It is possible with the alv list display. Hence you can have the header and footer too.

Regards,

Sankar.

11 REPLIES 11
Read only

Former Member
0 Likes
1,262

Yes you can. It is possible with the alv list display. Hence you can have the header and footer too.

Regards,

Sankar.

Read only

0 Likes
1,261

I mean just like top-of-page will appear for every page..is there any possibiity of appearing of end-of-page everytime the page trigger's?

if so can any one having the code..?

Read only

0 Likes
1,261

Hi,

Yes, It will. U can use end-of-page if it has to appear in every page. If u want the code to occur only once in the end of all pages, use end-of-list.

Regards,

ramya

Read only

0 Likes
1,261

Ramya can iu send em the code regarding that..

actually i am expecting the output just like the normal classical report which will trigger the end-of-page each page

Hope u understand my question(requirement)

Read only

0 Likes
1,261

Please kindly reply this..its very urguent for me

Read only

0 Likes
1,261

Hi,

You can see the end of the page only in the spool for every page. Like classical report you cannot view this.

Please refer to the code below for end of page.


 DATA: gt_events     type slis_t_event,
       gd_prntparams type slis_print_alv.


 call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            it_events               = gt_events  
            is_print                = gd_prntparams  
            i_save                  = 'X'
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.


 perform build_events.
 perform build_print_params.

*&------------------------------------------------------------------*
*&      Form  BUILD_EVENTS
*&------------------------------------------------------------------*
*       Build events table
*-------------------------------------------------------------------*
form build_events.
  data: ls_event type slis_alv_event.

  call function 'REUSE_ALV_EVENTS_GET'
       exporting
            i_list_type = 0
       importing
            et_events   = gt_events[].
  read table gt_events with key name =  slis_ev_end_of_page
                           into ls_event.
  if sy-subrc = 0.
    move 'END_OF_PAGE' to ls_event-form.
    append ls_event to gt_events.
  endif.

    read table gt_events with key name =  slis_ev_end_of_list
                           into ls_event.
  if sy-subrc = 0.
    move 'END_OF_LIST' to ls_event-form.
    append ls_event to gt_events.
  endif.
endform.                    " BUILD_EVENTS


*&------------------------------------------------------------------*
*&      Form  BUILD_PRINT_PARAMS
*&------------------------------------------------------------------*
*       Setup print parameters
*-------------------------------------------------------------------*
form build_print_params.
  gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
  gd_prntparams-no_coverpage = 'X'.
endform.                    " BUILD_PRINT_PARAMS

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
1,261

Hi

Yes.in alv you can use end-of-page event for footer.

Read only

Former Member
0 Likes
1,261

Hi,

Ya. It can be used. Refer below.

*Get all possible events

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = lt_event

exceptions

list_type_wrong = 1

others = 2.

if sy-subrc <> 0.

endif.

  • Specify events used in selection screen

read table lt_event with key name = slis_ev_end_of_page

into ls_event.

if sy-subrc = 0.

ls_event-form = 'END_OF_PAGE'.

modify lt_event from ls_event index sy-tabix.

clear ls_event.

endif.

form end_of_page .

write:

write:

endform.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

it_fieldcat = it_fieldcatalog

it_events = lt_event

tables

t_outtab = gt_output

exceptions

program_error = 1

others = 2.

Reward if helpful.

Regards,

Ramya

.

Read only

Former Member
0 Likes
1,261

Hi,

Yes u can display the footer in ALV, try this example u can get the solution.

ALV GRID REPORT WITH HEADER AND FOOTER DISPLAY.

TABLES VBAK.

TYPE-POOLS SLIS.

  • Data Declaration

TYPES: BEGIN OF T_VBAK,

VBELN TYPE VBAK-VBELN,

ERDAT TYPE VBAK-ERDAT,

ERNAM TYPE VBAK-ERNAM,

AUDAT TYPE VBAK-AUDAT,

VBTYP TYPE VBAK-VBTYP,

NETWR TYPE VBAK-NETWR,

VKORG TYPE VBAK-VKORG,

VKGRP TYPE VBAK-VKGRP,

LINE_COLOR(4) TYPE C,

END OF T_VBAK.

DATA: IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0,

WA_VBAK TYPE T_VBAK.

  • ALV Data Declaration

DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

GD_REPID TYPE SY-REPID,

I_EVENTS TYPE SLIS_T_EVENT,

W_EVENTS LIKE LINE OF I_EVENTS.

DATA: I_COMMENT TYPE SLIS_T_LISTHEADER,

WA_COMMENT TYPE SLIS_LISTHEADER.

START-OF-SELECTION.

PERFORM DATA_RETRIEVAL.

PERFORM BLD_FLDCAT.

PERFORM BLD_LAYOUT.

PERFORM CALL_EVENTS.

PERFORM DISPLAY_ALV_REPORT.

  • Build Field Catalog for ALV Report

FORM BLD_FLDCAT.

FLDCAT-FIELDNAME = 'VBELN'.

FLDCAT-SELTEXT_M = 'Sales Document'.

FLDCAT-COL_POS = 0.

*FLDCAT-EMPHASIZE = 'C411'.

FLDCAT-OUTPUTLEN = 20.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERDAT'.

FLDCAT-SELTEXT_L = 'Record Date created'.

FLDCAT-COL_POS = 1.

FLDCAT-KEY = 'X'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'ERNAM'.

FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'AUDAT'.

FLDCAT-SELTEXT_M = 'Document Date'.

FLDCAT-COL_POS = 3.

FLDCAT-EMPHASIZE = 'C110'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VBTYP'.

FLDCAT-SELTEXT_L = 'SD Document category'.

FLDCAT-COL_POS = 4.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'NETWR'.

FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.

FLDCAT-COL_POS = 5.

FLDCAT-OUTPUTLEN = 60.

FLDCAT-DO_SUM = 'X'.

FLDCAT-DATATYPE = 'CURR'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKORG'.

FLDCAT-SELTEXT_L = 'Sales Organization'.

FLDCAT-COL_POS = 6.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

FLDCAT-FIELDNAME = 'VKGRP'.

FLDCAT-SELTEXT_M = 'Sales Group'.

FLDCAT-COL_POS = 7.

FLDCAT-EMPHASIZE = 'C801'.

APPEND FLDCAT TO FLDCAT.

CLEAR FLDCAT.

ENDFORM.

  • Build Layout for ALV Grid Report

FORM BLD_LAYOUT.

GD_LAYOUT-NO_INPUT = 'X'.

GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

GD_LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.

ENDFORM.

  • Display report using ALV grid

FORM DISPLAY_ALV_REPORT.

DATA T_EVENT TYPE SLIS_T_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = T_EVENT.

IF SY-SUBRC <> 0.

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

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

ENDIF.

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = GD_REPID

IS_LAYOUT = GD_LAYOUT

  • I_CALLBACK_HTML_TOP_OF_PAGE = 'TOP_OF_PAGE_SPLIT'

I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'

  • I_CALLBACK_HTML_END_OF_LIST = 'END_OF_LIST_HTML'

IT_EVENTS = I_EVENTS

IT_FIELDCAT = FLDCAT[]

I_SAVE = 'X'

TABLES

T_OUTTAB = IT_VBAK

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.

  • Retrieve data from VBAK table and populate itab IT_VBAK

FORM DATA_RETRIEVAL.

DATA LD_COLOR(1) TYPE C.

SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG

UP TO 100 ROWS

FROM VBAK

INTO TABLE IT_VBAK.

LOOP AT IT_VBAK INTO WA_VBAK.

LD_COLOR = LD_COLOR + 1.

IF LD_COLOR = 8.

LD_COLOR = 1.

ENDIF.

CONCATENATE 'C' LD_COLOR '10' INTO WA_VBAK-LINE_COLOR.

MODIFY IT_VBAK FROM WA_VBAK.

ENDLOOP.

ENDFORM.

FORM TOP-OF-PAGE.

WA_COMMENT-TYP = ‘H’.

WA_COMMENT-INFO = ‘WELCOME TO HEADER’.

APPEND WA_COMMENT TO I_COMMENT.

CLEAR WA_COMMENT.

CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE’

EXPORTING

IT_LIST_COMMENTARY = I_COMMENT.

ENDFORM.

FORM CALL_EVENTS.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = I_EVENTS

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 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.

IF NOT I_EVENTS[] IS INITIAL.

READ TABLE I_EVENTS INTO W_EVENTS WITH KEY NAME = 'END_OF_LIST'.

W_EVENTS-FORM = 'GENERATE_USERCOMMAND_FOOTER'.

MODIFY I_EVENTS FROM W_EVENTS INDEX SY-TABIX.

ENDIF.

ENDFORM.

FORM GENERATE_USERCOMMAND_FOOTER.

CLEAR I_COMMENT[].

WA_COMMENT-TYP = 'H'.

WA_COMMENT-INFO = 'CHANDU'(019).

APPEND WA_COMMENT TO I_COMMENT.

CLEAR I_COMMENT[].

WA_COMMENT-TYP = 'S'.

WA_COMMENT-INFO = SY-PAGNO.

APPEND WA_COMMENT TO I_COMMENT.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = I_COMMENT

  • I_LOGO = ''

I_END_OF_LIST_GRID = 'X'.

ENDFORM.

Regards,

Chandu.

Read only

Former Member
0 Likes
1,261

hi sap guru ,

cn any one tell me wht is the name of active table ? for example 'DWINACTIV' is the name of inactive table so for active table what ? THX IN ADDVN

Read only

Former Member
0 Likes
1,261

Hi,

You can have footer in the alv too. If you use class methord then just under the container in the layout design the footer according to your need.for example you want to display some text then choose the text from left and put it where you want and right the text under it or suppose you want to display some dynamic value then select the i/o and put it where you want to display and make it only output in the screen painter editor . In this way you canget the footer.

If you use function module then you can do it like this . I am sending code use it .

DATA: t_f080_top_of_page TYPE slis_t_listheader.

DATA: t_events TYPE slis_t_event WITH HEADER LINE.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = wa_layout

it_fieldcat = i_fieldcat

it_events = t_events[]

TABLES

t_outtab = t_output

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. " IF sy-subrc <> 0.

&----


*& Form f070_COMMENT_BUILD

&----


  • text

----


  • -->e04_t_f080_top_of_page text

----


FORM f070_comment_build USING e04_t_f080_top_of_page

TYPE slis_t_listheader.

t_events-form = 'END_OF_PAGE'.

t_events-name = 'END_OF_PAGE'.

APPEND t_events.

DATA: ls_line TYPE slis_listheader.

  • Type H

CLEAR ls_line.

ls_line-typ = 'H'.

ls_line-info = 'CPU Calculation'.

APPEND ls_line TO e04_t_f080_top_of_page.

  • Kopfinfo: Typ S

CLEAR ls_line.

ls_line-typ = 'S'.

ls_line-key = 'Total amount'.

ls_line-info = fs_total_amount.

APPEND ls_line TO e04_t_f080_top_of_page.

ls_line-key = 'Total Entries'.

ls_line-info = fs_total_entries.

APPEND ls_line TO e04_t_f080_top_of_page.

ls_line-key = 'Total CPU'.

ls_line-info = fs_total_cpu.

APPEND ls_line TO e04_t_f080_top_of_page.

ENDFORM. "f070_COMMENT_BUILD

&----


*& Form f080_top_of_page

&----


  • text

----


FORM END_of_page.

*

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

  • i_logo = 'HTMLCNTL_TESTHTM2_SAPLOGO'

  • I_LOGO = 'ENJOYSAP_LOGO'

it_list_commentary = t_f080_top_of_page[].

ENDFORM. "f080_top_of_page

But you cann't see it in display you will get it when you print this .

You can only see it if you select top of page then it will be header not footer so use any methord according to your need.

Reward some point.

Bye,

Anomitro