cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP List Viewer

Former Member
0 Kudos

Hi all,

I am trying to display footer in the ALV using list display. Though my code seems to be correct the footer as I expected is not getting printed.I am forwarding the whole code can any please check and tell me where I am going wrong.

*********************************************************

REPORT z_v_alv_list_display_event NO STANDARD PAGE HEADING.

*----Tables Declaration.

TABLES : mara.

*----Type pools Declaration.

TYPE-POOLS : slis.

DATA : r_repid LIKE sy-repid.

*----Fieldcatalog Simulation.

DATA : f_fieldcat TYPE slis_t_fieldcat_alv.

DATA : e_events TYPE slis_t_event.

DATA : wa_events TYPE slis_alv_event.

*----Field catalog is a table containing the

  • properties and attributes

  • columns/fields of the output internal table.

*----Internal Table declaration

DATA : BEGIN OF i_mara OCCURS 0,

matnr LIKE mara-matnr, " Material Number

ersda LIKE mara-ersda, " Creation date

ernam LIKE mara-ernam, " Name of Person who Created the Object

pstat LIKE mara-pstat, " Maintenance status

END OF i_mara.

*----Start of selection Event.

START-OF-SELECTION.

*---- Dumping data into internal table.

SELECT matnr ersda ernam pstat FROM mara INTO TABLE i_mara.

PERFORM fieldcatalog_merge.

PERFORM events_get.

PERFORM list_display.

DATA num TYPE i VALUE 10.

&----


*& Form fieldcatalog_merge

&----


  • text

----


FORM fieldcatalog_merge.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

*---- I_PROGRAM_NAME is the name of the source program.

i_program_name = 'Z_V_ALV_LIST_DISPLAY_EVENT'

*---- I_INTERNAL_TABNAME : Name of the internal table

*---- which you are showing in the putput.

*---- Be sure to specify the name of internal table in CAPS.

i_internal_tabname = 'I_MARA'

*----I_INCLNAME : Name of the source program

  • in which internal table is defined.

i_inclname = 'Z_V_ALV_LIST_DISPLAY_EVENT'

CHANGING

ct_fieldcat = f_fieldcat.

*---- IN changing parameters specify the name

  • of the fieldcat you have declared.

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

&----


*& Form list_display

&----


  • text

----


FORM list_display.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

*---- i_bypassing_buffer :

  • When the program is run for the first time, the fields

  • present in the output table and their positions are stored

  • in a buffer.So the buffer is taken as reference for the successive

  • executions.In order to bypass this buffer the above parameter values

  • should be ‘X’ and ‘ ‘(space) respectively. If these values are not

  • passed to the function module, the changes made in the structure of

  • the internal table MAY NOT be reflected in the output.

i_bypassing_buffer = 'X'

i_buffer_active = ' '

*---- The program, which calls the function module and has the

  • exit routines.

i_callback_program = 'Z_V_ALV_LIST_DISPLAY_EVENT'

*----Pass the field catalog here

it_fieldcat = f_fieldcat

i_save = 'A'

*----This internal table tells the ALV, which events are

  • processed by the user CALLBACK

IT_EVENTS = e_events

TABLES

t_outtab = i_mara " internal table

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

&----


*& Form events_get

&----


FORM events_get .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = e_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.

READ TABLE e_events INTO WA_EVENTS

with KEY name = slis_ev_top_of_page.

IF sy-subrc = 0.

wa_events-form = 'TOP_OF_PAGE'.

APPEND wa_events TO e_events.

ENDIF.

READ TABLE e_events INTO WA_EVENTS

with KEY name = slis_ev_end_of_page.

IF sy-subrc = 0.

wa_events-form = 'END_OF_PAGE'.

APPEND wa_events TO e_events.

ENDIF.

ENDFORM. " events_get

**----


    • Form Top_Of_Page

**----


*Form TOP_OF_PAGE.

*

*Data : i_commentary type SLIS_T_LISTHEADER.

*Data : wa_Comementary type slis_listheader.

*

  • wa_comementary-typ = 'H'.

  • wa_comementary-info = 'THIS IS THE HEADER'.

  • Append wa_comementary to i_commentary.

*

*

  • CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

  • it_list_commentary = i_commentary

    • I_LOGO =

    • I_END_OF_LIST_GRID =

  • .

*

*

*

  • Endform.

form TOP_OF_PAGE.

write 35 'THIS IS MY HEADER' color 5.

endform.

form END_OF_PAGE.

write 35 'THIS IS MY FOOTER' color 4.

endform.

*********************************************************

Regards,

Varun.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Varun,

You are not populating the data at TOP_OF_PAGE and END_OF _PAGE.

form TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = ITAB_COMMENTS.

endform.

Then fill ITAB_COMMANTS:

WA_COMMENTS-TYP = 'H'.

WA_COMMENTS-INFO = 'TOP of Page' .

APPEND WA_COMMENTS TO ITAB_COMMENTS.

Hope this will resolve your issue.

Please see they are lot of SAP examples you can find by BCALV* in Transaction SE38.

Lanka

Former Member
0 Kudos

Hi Lanka,

With this code top of page is working properly. But end of page is not being displayed.

Regards,

Varun.

Former Member
0 Kudos

Hi Varun,

Please check SAP DEMO program : BCALV_TEST_LIST_EVENTS

Lanka

Former Member
0 Kudos

Hi Lanka,

Sorry to say this. That program is too complicated for me to understand. I dont understand why end of page doesn't work when top of page works fine .I have checked with other posts and programs in this forum everything seems similar but I do not understand why the footer is not displayed.

Regards,

Varun.

Former Member
0 Kudos

Hi Lanka,

Add Event functionality to ALVgrid report

In order to add event functionality such as 'END_OF_PAGE' to the ALV grid you need to setup the

IT_EVENTS option of the ALV function module. Also depending on which event you are using you

may also need to setup the print parameters by activating the IS_PRINT option. <b>Please note for events

such as end_of_page, end_of_list etc they will not be displayed on screen but only in the printed

output.</b>

I took this from the link :

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_events.htm

Is it true? If that is true I think my problem is solved because I am looking for the data on the screen not on the printed output.

Regards,

Varun.

Former Member
0 Kudos

Hi Varun ,

That is true.

Former Member
0 Kudos

Hi Varun,

I have noticed another issue with your events form

FOR TOP_OF_PAGE:

WA_EVENTS-NAME = 'TOP_OF_PAGE'.

WA_EVENTS-FORM = 'FRM_TOP_OF_PAGE'.

APPEND wa_events TO e_events.

FOR END_OF_PAGE:

WA_EVENTS-NAME = 'END_OF_PAGE'.

WA_EVENTS-FORM = 'FRM_END_OF_PAGE'.

APPEND wa_events TO e_events.

change the above and try.

<u>Events like END_OF---will Print only on O/P</u>

Lanka

Former Member
0 Kudos

Hi Lanka,

I dont think this is necessary because

‘REUSE_ALV_EVENTS_GET’ - This function module returns an internal table having two fields NAME and FORM. The NAME field will have the list of all the events that can be handled in ALV. The FORM field will be blank when the FM returns the internal table.If u debug the program and see the contents of e_events (this is in my program)

u can see all the events.

Regards,

Varun.

Former Member
0 Kudos

Hi Varun,

Even though the FM you refered has all the names of the event ,you need to specify the form for the events explicitly & pass it to the events internal table in your case e_events & you can see your COMMENTS at the end of page..ie your end_of_page would fire.

You can pass this way in you EVENT building perform.

READ TABLE LT_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 LT_EVENTS.

ENDIF.

-


FORM END_OF_PAGE.

WRITE at (sy-linsz) sy-pagno CENTERED.

ENDFORM.

Former Member
0 Kudos

Hi Varun,

Pls try this & see if it helps....i have not tried this...

When calling the FM 'REUSE_ALV_COMMENTARY_WRITE' in the END_OF_PAGE, pass the import parameter I_END_OF_LIST_GRID as 'X'...

If you are already doing this...pls ignore my reply...

Thanks,

Renjith