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: 

Top_Of_Page event in OOALV

Former Member
0 Kudos

Hi

Iam working on ALV Grid Control in ABAP using OOPS but in that the top of page event has not fired. Any one help me by giving sequence of code?

Thanks & Regards

venkat

7 REPLIES 7

former_member181962
Active Contributor
0 Kudos

Refer this blog:

/people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid

Regards,

Ravi

Former Member
0 Kudos

Hi,

In REUSE_ALV_GRID_DISPLAY, you have a parameter

TOP_OF_PAGE, pass your top-of-page sub routine to this parameter,

& add it in your events table as well.

hope this helps you.

Regards,

Raghavendra

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

----


  • CLASS v_lcl_event_receiver DEFINITION

----


CLASS v_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.

----


  • CLASS V_LCL_EVENT_RECEIVER IMPLEMENTATION

----


CLASS v_lcl_event_receiver IMPLEMENTATION.

METHOD handle_print_top_of_page.

IF sy-pagno = 1.

PERFORM top_of_page.

ENDIF.

ENDMETHOD.

METHOD handle_top_of_page.

PERFORM top_of_page.

ENDMETHOD.

ENDCLASS.

DATA: v_event_receiver TYPE REF TO v_lcl_event_receiver.

FORM top_of_page.

WRITE: text-020,

/

ENDFORM. " top_of_page

In PBo of the screen

DATA: v_split TYPE REF TO cl_gui_easy_splitter_container,

v_contnr_top TYPE REF TO cl_gui_container,

v_contnr_bot TYPE REF TO cl_gui_container,

v_grid_02 TYPE REF TO cl_gui_alv_grid,

v_html TYPE REF TO cl_dd_document,

v_text20(255) TYPE c,

v_text16(255) TYPE c,

FORM f9000_objects_create.

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

Create a container

CREATE OBJECT o_dockingcontainer

EXPORTING

ratio = '95'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

IF sy-subrc NE 0.

MESSAGE i000 WITH text-e01."Error in creating Docking container

LEAVE LIST-PROCESSING.

ENDIF.

CREATE OBJECT v_split

EXPORTING

parent = o_dockingcontainer

  • ORIENTATION = 0

sash_position = 25

with_border = 0

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

others = 3.

IF sy-subrc NE 0.

MESSAGE i000 WITH text-e01."Error in creating Docking container

LEAVE LIST-PROCESSING.

ENDIF.

  • Get the containers of the splitter control

v_contnr_top = v_split->top_left_container.

v_contnr_bot = v_split->bottom_right_container.

CREATE OBJECT o_alvgrid

EXPORTING

i_parent = o_dockingcontainer.

  • Create an instance of alv control

CREATE OBJECT o_alvgrid

EXPORTING i_parent = v_contnr_bot.

  • Object for display of selection parameters in HTML top container

CREATE OBJECT v_html

EXPORTING

style = 'ALV_GRID'.

  • Must be after the SET HANDLER for TOP_OF_PAGE and foreground only

CALL METHOD o_alvgrid->list_processing_events

EXPORTING i_event_name = 'TOP_OF_PAGE'

i_dyndoc_id = v_html.

v_text20 = text-020(summary Record counts)Any text.

CALL METHOD v_html->add_gap

EXPORTING

width = 120.

CALL METHOD v_html->add_text

EXPORTING

text = v_text20.

CALL METHOD v_html->new_line.

    • Display Text-016

v_text16 = text-016.

CALL METHOD v_html->add_gap

EXPORTING

width = 1.

CALL METHOD v_html->add_text

EXPORTING

text = v_text16.

v_text16 = v_sap_recon.

CALL METHOD v_html->add_gap

EXPORTING

width = 1.

CALL METHOD v_html->add_text

EXPORTING

text = v_text16.

CALL METHOD v_html->new_line.

  • Display the data

CALL METHOD v_html->display_document

EXPORTING

parent = v_contnr_top.

  • Handle the event

CALL METHOD o_alvgrid->list_processing_events

EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.

IN PBO while populating in the output table

FORM f9004_display_data TABLES p_report_tab

p_fieldcat.

CALL METHOD o_alvgrid->set_table_for_first_display

EXPORTING

is_variant = w_variant

i_save = c_a

is_layout = w_layout

CHANGING

it_outtab = p_report_tab[]

it_fieldcatalog = p_fieldcat[]

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4. IF sy-subrc <> 0.

MESSAGE i000 WITH text-e06."Error in ALV report display

LEAVE LIST-PROCESSING.

ENDIF.

  • Create object

IF v_event_receiver IS INITIAL.

CREATE OBJECT v_event_receiver.

ENDIF.

SET HANDLER v_event_receiver->handle_print_top_of_page FOR o_alvgrid.

SET HANDLER v_event_receiver->handle_top_of_page FOR o_alvgrid.

This is an example for docking container u have to split the container and in one part u will be dispalying TOP-OF_pAGE in the other the grid.

If u want more help get back to me.

CALL METHOD gd_userlist->set_table_for_first_display

EXPORTING

is_hierarchy_header = gd_hierarchy_header

it_list_commentary = gd_report_title i_logo = gd_logo

i_save = 'A'

is_variant = gd_variant

CHANGING

it_outtab = it_emptytab "Must be empty

it_fieldcatalog = gd_fieldcat.

0 Kudos

Hi,

i have to use Top_of_page event, is it necessary to use Split and docking container for this ? please help me on this, i need it urgently.

Regards,

Nilanjana

0 Kudos

Hi Nilanjana,

Its not mandatory to use split or docking container for using the TOP_OF_PAGE. You can use two separate containers

in the screen for the purpose. But its preferable to use docking or splitting container as the buffer space reqd is

considerably low compared to placing two differebnt containers on screen.

You can use the class CL_DD_DOCUMENT for having TOP_OF_PAGE in ABAP OO. In order to trigger the TOP_OF_PAGE event

the method LIST_PROCESSING_EVENTS of the class CL_GUI_ALV_GRID must be called. And in the event handler method you

have to build the TOP_OF_PAGE using the different methods available in the class CL_DD_DOCUMENT (for example the

method ADD_TEXT is used to add text to the TOP_OF_PAGE).

Thanks and Regards,

Rahul MB

chandra_sekhar3
Explorer
0 Kudos

Hi,

Top-Of-Page is only tiggered while u display GRID output as a list or u r printing the report.

In OOPS , u have to use Event handler for class "cl_gui_alv_grid" and event name is "print_top_of_page".

The following function is called from top of page

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

I_LOGO = 'ENJOYSAP_LOGO'

IT_LIST_COMMENTARY = SD_HEADING.

ENDFORM. "TOP_OF_PAGE

Clemenss
Active Contributor
0 Kudos

Hi venkateswarao g...,

the blog Ravi mentions is exactly what you need.

Only in Full screen mode (as used by FM REUSE_ALV_GRID_DISPLAY) the grid will use it's own screen and create the required containers for TOP, grid and bottom area.

If you use your own container, you have to put a splitter container into it using the first row for top-of-page and the second row for the grid itself.

Think about this and then read the blog posted by Vijay Babu Dudla - it is much easier than it looks.

Regards,

Clemens