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 HEADER

Former Member
0 Likes
1,335

hi experts,

m making an alv report..i want a text to b displayed on the top of the page..how cud i do that.rewards will b given.

regards,

raman

hi experts,

m making an alv report..i want a text to b displayed on the top of the page..how cud i do that.rewards will b given.

regards,

raman

10 REPLIES 10
Read only

Former Member
0 Likes
1,305

Hi,

In order to insert a report heading in to the ALV grid you need to perform the following steps:

1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'top-of-page' FORM

2. Create 'top-of-page' FORM

Check the following code:

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

exceptions

program_error = 1

others = 2.

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


Form top-of-page.

*ALV Header declarations

data: t_header type slis_t_listheader,

wa_header type slis_listheader,

t_line like wa_header-info,

ld_lines type i,

ld_linesc(10) type c.

  • Title

wa_header-typ = 'H'.

wa_header-info = 'EKKO Table Report'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum(4) INTO wa_header-info. "todays date

append wa_header to t_header.

clear: wa_header.

  • Total No. of Records Selected

describe table it_ekko lines ld_lines.

ld_linesc = ld_lines.

concatenate 'Total No. of Records Selected: ' ld_linesc

into t_line separated by space.

wa_header-typ = 'A'.

wa_header-info = t_line.

append wa_header to t_header.

clear: wa_header, t_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_header.

  • i_logo = 'Z_LOGO'.

endform.

Regards,

Chandru

Read only

Former Member
0 Likes
1,305

If ur dispalying list display...

Then populate events tab ..

FORM sub_configure_for_pageheader .

DATA: is_event TYPE slis_alv_event .

REFRESH : it_events.

  • Get a list of all possible events that can get triggered

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc = 0.

SORT it_events BY name .

CLEAR: is_event .

  • Get the Record for the Event Corresponding to TOP_OF_PAGE

READ TABLE it_events INTO is_event WITH KEY name = slis_ev_top_of_page

BINARY SEARCH .

IF sy-subrc = 0.

  • For TOP_OF_PAGE Event, the Subroutine to be Called is SUB_TOP_OF_PAGE

MOVE 'SUB_TOP_OF_PAGE' TO is_event-form.

MODIFY it_events FROM is_event INDEX sy-tabix .

CLEAR is_event .

ENDIF.

endform.

FORM sub_top_of_page.

WRITE: /1 text-012 , 20 s_eindt-low.

WRITE: 40 text-013 , 60 s_eindt-high.

endform.

pass the event tab to ur FM dispaly...

Read only

Former Member
0 Likes
1,305

Hi

Refer this program:

PERFORM build_events USING '3'

CHANGING gt_events3.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = gs_layout

it_fieldcat = lt_fieldcat

i_tabname = 'ITAB3'

it_events = gt_events3

TABLES

t_outtab = itab3

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

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 top_of_page1

*&----


*

FORM top_of_page1.

WRITE: 'Last Year'.

ENDFORM. "TOP_OF_PAGE1

*&----


*

*& Form top_of_page2

*&----


*

FORM top_of_page2.

WRITE: 'Budget'.

ENDFORM. "TOP_OF_PAGE2

*&----


*

*& Form top_of_page3

*&----


*

FORM top_of_page3.

WRITE: 'This year'.

ENDFORM. "TOP_OF_PAGE3

*&----


*

*& Form build_events

*&----


*

    • text*

*----


*

    • --> p1 text*

    • <-- p2 text*

*----


*

FORM build_events USING flag

CHANGING pa_events TYPE slis_t_event.

*Get all possible events

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = pa_events

EXCEPTIONS

list_type_wrong = 1

OTHERS = 2.

IF sy-subrc <> 0.

ENDIF.

    • Specify events used in selection screen*

READ TABLE pa_events WITH KEY name = slis_ev_top_of_page

INTO ls_events.

IF sy-subrc = 0.

IF flag = 1.

ls_events-form = 'TOP_OF_PAGE1'.

ELSEIF flag = 2.

ls_events-form = 'TOP_OF_PAGE2'.

ELSE.

ls_events-form = 'TOP_OF_PAGE3'.

ENDIF.

MODIFY pa_events FROM ls_events INDEX sy-tabix.

CLEAR ls_events.

ENDIF.

ENDFORM. "build_events

Thanks

Vasudha

Edited by: Vasudha L on Feb 19, 2008 10:41 AM

Read only

Former Member
0 Likes
1,305

hi,

try this code.

data: gt_list_top_of_page type slis_t_listheader.

Initialization.

perform f5200_build_header using gt_list_top_of_page[].

Top-of-page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = gt_list_top_of_page

exceptions

others = 1.

form f5200_build_header using e04_lt_top_of_page type slis_t_listheader.

data: ls_line type slis_listheader.

clear ls_line.

ls_line-typ = 'H'.

ls_line-info = 'TEST'.

append ls_line to e04_lt_top_of_page.

endform. " F5200_BUILD_HEADER

[/code]

Read only

Former Member
0 Likes
1,305

Hi

U need to use the event ALV TOP_OF_PAGE, so in the table of the events transfer the routine to be used for that event, and insert the code you need in that routine:

- to tranfer the routine to ALV:

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
LS_EVENT-NAME = 'TOP_OF_PAGE'.
LS_EVENT-FORM  = 'TOP-OF-PAGE'.
APPEND LS_EVENT TO GT_EVENTS.

GT_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   ..............
   I_CALLBACK_PROGRAM       = GT_REPID
   ............
   IT_EVENTS                           = GT_EVENTS
  ....................

- Insert your code in the routine:

FORM TOP-OF-PAGE.
  WRITE: / 'TOP_OF_PAGE'.
ENDFORM.

Max

Read only

Former Member
0 Likes
1,305

Hi

check this code in this top-of-page event is there

TYPE-POOLS : slis.

----


  • STRUCTURE DECLARATION

----


TYPES: BEGIN OF st_ekpo,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

matnr TYPE ekpo-matnr,

netwr TYPE ekpo-netwr,

END OF st_ekpo.

----


  • INTERNAL TABLE DECLARATION

----


DATA: it_ekpo TYPE STANDARD TABLE OF st_ekpo ,

it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

v_ebeln TYPE ekpo-ebeln,

wa_layout TYPE slis_layout_alv,

it_listheader TYPE slis_t_listheader ,

wa_listheader LIKE LINE OF it_listheader,

it_events TYPE slis_t_event,

st_event LIKE LINE OF it_events.

SELECT-OPTIONS so_ebeln FOR v_ebeln.

----


  • START-OF-SELECTION

----


START-OF-SELECTION.

SELECT ebeln ebelp matnr netwr

FROM ekpo

INTO TABLE it_ekpo

WHERE ebeln IN so_ebeln.

PERFORM populate_feildcat.

PERFORM populate_layout.

PERFORM event_list.

PERFORM display.

&----


*& Form populate_feildcat

&----


FORM populate_feildcat .

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_l = 'DOCUMENT NUMBER'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_l = 'ITEM DOCUMENT NUMBER'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-seltext_l = 'MATERIAL'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'NETWR'.

wa_fieldcat-seltext_l = 'NET VALUE'.

APPEND wa_fieldcat TO it_fieldcat.

ENDFORM. " populate_feildcat

&----


*& Form populate_layout

&----


FORM populate_layout .

wa_layout-colwidth_optimize = 'X'. "column width

wa_layout-zebra = 'X'.

wa_layout-window_titlebar = text-000.

ENDFORM. " populate_layout

&----


*& Form event_list

&----


FORM event_list .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

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

READ TABLE it_events WITH KEY name = slis_ev_top_of_page INTO st_event.

IF SY-SUBRC = 0.

ST_EVENT-FORM = 'TOP_OF_PAGE'.

APPEND ST_EVENT TO IT_EVENTS.

CLEAR ST_EVENT.

ENDIF.

READ TABLE it_events WITH KEY name = slis_ev_end_of_page INTO st_event.

IF sy-subrc EQ 0.

st_event-form = 'END_OF_PAGE'.

APPEND st_event TO it_events.

CLEAR st_event.

ENDIF.

READ TABLE it_events WITH KEY name = slis_ev_pf_status_set INTO st_event.

IF sy-subrc EQ 0.

st_event-form = 'SET_PF_STATUS1'.

APPEND st_event TO it_events.

CLEAR st_event.

ENDIF.

ENDFORM. " event_list

&----


*& Form display

&----


FORM display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

I_BACKGROUND_ID = 'BVRLOGO'

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'AT_USER_COMMAND'

is_layout = wa_layout

it_fieldcat = it_fieldcat

it_events = it_events

TABLES

t_outtab = it_ekpo

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

&----


*& Form top_of_page

&----


FORM top_of_page.

REFRESH it_listheader.

wa_listheader-typ = 'H'.

wa_listheader-info = text-001.

APPEND wa_listheader TO it_listheader.

CLEAR wa_listheader.

wa_listheader-typ = 'S'.

wa_listheader-info = text-002.

APPEND wa_listheader TO it_listheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader[]

I_LOGO = 'FITP_CORP_LOGO'.

ENDFORM. "TOP_OF_PAGE

&----


*& Form END_OF_PAGE

&----


FORM end_of_page.

REFRESH it_listheader.

wa_listheader-typ = 'H'.

wa_listheader-info = sy-pagno.

APPEND wa_listheader TO it_listheader.

CLEAR wa_listheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader[].

ENDFORM. "end_of_page

&----


*& Form SET_PF_STATUS

&----


FORM set_pf_status1 USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STANDARD' .

ENDFORM. "SET_PF_STATUS

&----


*& Form AT_USER_COMMAND

&----


FORM at_user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'SE11'.

CALL TRANSACTION 'SE11'.

WHEN 'SE38'.

CALL TRANSACTION 'SE38'.

ENDCASE.

ENDFORM. "at_user_command

Read only

Former Member
0 Likes
1,305

hi,

see the following example.

perform build_listheader using it_listheader.

form build_listheader using it_listheader type slis_t_listheader.

data hline type slis_listheader.

hline-info = 'This is alv interactive program'.

hline-typ = 'H'.

append hline to it_listheader.

endform. "build_listheader

form top_of_page.

write : 'This is top of page'.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = it_listheader.

endform.

hope it is useful.

regards,

sreelakshmi.

Read only

Former Member
0 Likes
1,305

Funtion module REUSE_ALV_GRID_DISPLAY

Exporting parameter I_CALLBACK_HTML_TOP_OF_PAGE.

I have used this and it worked for me.

Read only

Former Member
0 Likes
1,305

hi use this function module.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

in that you have export parameter

I_GRID_TITLE = 'specify ur title'.

check it out

Read only

Former Member
0 Likes
1,305

Hi,

Please refer to the link below:

http://www.sapdev.co.uk/reporting/alv/alvgrid_rephead.htm

Thanks,

Sriram Ponna.