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: 

CL_GUI_ALV_GRID event TOP_OF_PAGE

Former Member
0 Kudos

Hi there,

I found when searching older threads about the same problem but no solution. I have also an ALV program and have registered the event TOP_OF_PAGE (NOT PRINT_TOP_OF_PAGE). The event ist not fired and not processed. As other peoples programs also mine can use print_top_of_page or e.g. hotspot_click without problems.

This is the relevant part of my code. Program does not reach the break-point.

DATA: gfd_title_doc_1 TYPE REF TO cl_dd_document.

CLASS lcl_event_handler_1 DEFINITION DEFERRED.

DATA: gfd_event_receiver_1 TYPE REF TO lcl_event_handler_1.

*----


  • CLASS DEFINITION

*----


*Event Handler

CLASS lcl_event_handler_1 DEFINITION.

PUBLIC SECTION.

CLASS-METHODS:

on_top_of_page_1 FOR EVENT top_of_page OF cl_gui_alv_grid

IMPORTING e_dyndoc_id,

ENDCLASS. "lcl_event_handler DEFINITION

*----


  • CLASS IMPLEMENTATION

*----


  • Event Handler

CLASS lcl_event_handler_1 IMPLEMENTATION.

METHOD on_top_of_page_1.

break z00238pw.

PERFORM top_of_page_1 USING e_dyndoc_id.

ENDMETHOD. "on_print_top_of_page

ENDCLASS. "lcl_event_handler IMPLEMENTATION

...

IF gfd_custom_container_1 IS INITIAL.

CREATE OBJECT gfd_custom_container_1

EXPORTING

container_name = gfd_container_1.

CREATE OBJECT gfd_grid_1

EXPORTING

i_parent = gfd_custom_container_1.

  • Create ALV

CALL METHOD gfd_grid_1->set_table_for_first_display

EXPORTING

i_structure_name = gc_structure_1

is_variant = gwa_variant_1

is_layout = gwa_layout_1

i_save = gc_save_all

  • it_toolbar_excluding = i_excl_alv

CHANGING

it_outtab = git_list_1

it_fieldcatalog = git_fieldcat_1

it_sort = git_sort_1

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CREATE OBJECT gfd_title_doc_1.

CALL METHOD gfd_title_doc_1->initialize_document.

CALL METHOD gfd_grid_1->list_processing_events

EXPORTING

i_event_name = 'TOP_OF_PAGE'

i_dyndoc_id = gfd_title_doc_1.

CREATE OBJECT gfd_event_receiver_1.

ENDIF.

SET HANDLER:

gfd_event_receiver_1->on_top_of_page_1 FOR gfd_grid_1.

Thank you in advance for your help

Axel

5 REPLIES 5

Former Member
0 Kudos

No ideas at all?

Former Member
0 Kudos

Hi,

Refer this sample code:

----


  • CLASS v_lcl_event_receiver DEFINITION

----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS:

handle_print_top_of_page FOR EVENT print_top_of_page OF

cl_gui_alv_grid,

handle_top_of_page FOR EVENT top_of_page OF

cl_gui_alv_grid,

ENDCLASS. "o_lcl_event_receiver DEFINITION

data: o_event_receiver TYPE REF TO lcl_event_receiver,

o_html TYPE REF TO cl_dd_document.

----


  • CLASS LCL_EVENT_RECEIVER IMPLEMENTATION

----


CLASS lcl_event_receiver IMPLEMENTATION.

*-- Top of Page

METHOD handle_print_top_of_page.

ENDMETHOD. "handle_print_top_of_page

METHOD handle_top_of_page.

ENDMETHOD. "handle_top_of_page

ENDCLASS. "lcl_event_receiver IMPLEMENTATION

*--Get the containers of the splitter control

o_container_top = o_split->top_left_container.

o_container_bot = o_split->bottom_right_container.

ENDIF.

CREATE OBJECT o_alvgrid

EXPORTING

i_parent = o_container_bot.

*-- Print Top of Page

PERFORM f0041_top_of_page.

FORM f0041_top_of_page.

*

DATA: lws_text TYPE sdydo_text_element.

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

*-- Object for HTML top container

CREATE OBJECT o_html

EXPORTING style = 'ALV_GRID'

background_color = 35.

*-- Top of Page

CALL METHOD o_alvgrid->list_processing_events

EXPORTING

i_event_name = 'TOP_OF_PAGE'

i_dyndoc_id = o_html.

*

*-- Total Record Text

CALL METHOD o_html->add_text

EXPORTING

text = text-049

sap_emphasis = text-051.

*

CALL METHOD o_html->add_gap

EXPORTING

width = 8.

**-- Total record Value

lws_text = cnt_total.

CALL METHOD o_html->add_text

EXPORTING

text = lws_text

sap_emphasis = text-051.

CLEAR lws_text.

CALL METHOD o_html->new_line

EXPORTING

repeat = 1.

*-- Display Report Header

CALL METHOD o_html->display_document

EXPORTING

parent = o_container_top.

ENDIF.

ENDFORM. " f0041_top_of_page

<b>Reward points if it helps,</b>

Satish

Former Member
0 Kudos

Sorry Satish,

but this is not what I asked for.

What I want to do, is to trigger the event TOP_OF_PAGE and to do something in the event handler. In the event handler there is a break point what is never reached.

What you do is, to implement the event handler but you never use it. Your header is idenpendent from any event and is just a static text printed in a separate container. That has nothing to do with event handling.

The problem is as it was that the PRINT_TOP_OF_PAGE event can be triggert but the TOP_OF_PAGE event is never triggered and this is the question not only in my thread - it is the question in all threads around this subject here in the forum.

Thank you anyhow.

May be that anyone else has an idea what's wrong here. By the way: I wonder why this event exists but is not documented. Is it possible, that this does not work even if I am in a 7.00 system??

Axel

ivan_ivanov
Explorer
0 Kudos

Hi,

I realize it is quite late for reply but ...

Try creating the event handler before calling the method set_table_for_first_display. I guess this is the reason for your issue.

Cheers,

Ivan

Clemenss
Active Contributor
0 Kudos

Hi Axel,

statistical the chance to get a useful answer is considerably higher if code is posted as code.

In the [How to post code in SCN.|; thread I did not see the simplest way: Select the pasted code with the mouse and hit the above <_> code button.

Regards,

Clemens