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: 

ALV

Former Member
0 Kudos

Hi,

How to handle the TOP OF PAGE and END OF PAGE events in ALV Grid Control.

Regards,

Srinu.

5 REPLIES 5

Former Member
0 Kudos

If you using the function module to display the ALV..Pass the events in the parameters IT_EVENTS to the function module...

You can get the events using the function module REUSE_ALV_EVENTS_GET..

Then add the event name and the form name to the internal table T_EVENTS and pass in the parameters IT_EVENTS...

THanks,

Naren

0 Kudos

hi,

if u have any sample code plz forward to me

0 Kudos

hi

check the below link..

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

Cheers,

Abdul Hakim

Former Member
0 Kudos

Hi,

Check this sample code..

TYPE-POOLS: slis.

DATA: BEGIN OF itab OCCURS 0,

vbeln TYPE vbeln,

END OF itab.

DATA: BEGIN OF itab1 OCCURS 0,

vbeln TYPE vbeln,

posnr TYPE posnr,

netpr TYPE netpr,

matnr TYPE matnr,

END OF itab1.

DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.

DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'VBELN'.

APPEND s_fieldcatalog TO t_fieldcatalog.

s_fieldcatalog-col_pos = '2'.

s_fieldcatalog-fieldname = 'POSNR'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'POSNR'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.

s_fieldcatalog-fieldname = 'NETPR'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'NETPR'.

s_fieldcatalog-do_sum = 'X'.

APPEND s_fieldcatalog TO t_fieldcatalog.

CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.

s_fieldcatalog-fieldname = 'MATNR'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'MATNR'.

s_fieldcatalog-ref_tabname = 'MARA'.

s_fieldcatalog-ref_fieldname = 'MATNR'.

s_fieldcatalog-edit = 'X'.

s_fieldcatalog-input = 'X'.

APPEND s_fieldcatalog TO t_fieldcatalog.

DATA: s_layout TYPE slis_layout_alv.

s_layout-subtotals_text = 'SUBTOTAL TEXT'.

s_layout-key_hotspot = 'X'.

SELECT vbeln UP TO 10 ROWS

FROM

vbak

INTO TABLE itab.

IF NOT itab[] IS INITIAL.

SELECT vbeln posnr netpr matnr

FROM vbap

INTO TABLE itab1

FOR ALL ENTRIES IN itab

WHERE vbeln = itab-vbeln.

ENDIF.

DATA: v_repid TYPE syrepid.

v_repid = sy-repid.

DATA: t_events TYPE slis_t_event.

DATA: s_events TYPE slis_alv_event.

s_events-name = 'TOP_OF_PAGE'.

s_events-form = 'FORM_TOP_OF_PAGE'.

APPEND s_events TO t_events.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

it_fieldcat = t_fieldcatalog

it_events = t_events

TABLES

t_outtab = itab1

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 FORM_TOP_OF_PAGE *

----


  • ........ *

----


FORM form_top_of_page.

DATA: ref TYPE REF TO cl_dd_document.

CREATE OBJECT ref.

DATA: ld_logo TYPE sdydo_value.

DATA: gt_header TYPE slis_t_listheader WITH HEADER LINE.

MOVE: 'H' TO gt_header-typ,

'Alv report' TO gt_header-info.

APPEND gt_header.

EXPORT it_list_commentary FROM gt_header

i_logo FROM ld_logo

TO MEMORY ID 'DYNDOS_FOR_ALV'.

CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'

EXPORTING

document = ref

bottom = ''

  • IMPORTING

  • LENGTH =

.

Thanks,

Naren

Former Member
0 Kudos

Hi,

Try this example..

an event table, which are used for firing both user commands and the system dependent events i.e. top of page, end of page etc.

A list of possible events is populated into an event table (I_EVENTS) when this table is passed to the function module REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.

The function module contains following import and export parameters.

IMPORTING PARAMETERS: I_LIST_TYPE

This parameter has possible values from 0-4.

The parameter I_LIST_TYPE is of TYPE SLIS_LIST_TYPE and is DEFAULT 0 .

EXPORTING PARAMETERS: I_EVENTS table.

This table is of TYPE SLIS_T_EVENT and returns to the program the name of all the possible events.

The table structure contains the fields:

I_EVENTS-NAME: Name of the Callback event.

I_EVENTS-FORM: Name of the form routine that should be called in the calling program at the event.

Only events with a form routine name are processed.

The I_EVENTS table returns with the following possible constants:

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

FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',

FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE', FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.

DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = I_EVENTS.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE

INTO L_I_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.

APPEND L_I_EVENT TO I_EVENTS.

ENDIF.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE

INTO L_I_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM.

APPEND L_I_EVENT TO I_EVENTS.

ENDIF.

CLEAR L_I_EVENT.

READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND

INTO L_I_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.

APPEND L_I_EVENT TO I_EVENTS.

ENDIF.

Hope this helps you.

Regards

Madhavi.