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: 

How to display some text at the top of the ALV Grid?

Former Member
0 Kudos

Hi Guys,

Can anybody tell me How to display some Text on the top of the ALV Grid in the ouput screen.

Thanks,

Gopi.

9 REPLIES 9

Former Member
0 Kudos

Gopi,

Use TOP_OF_PAGE event for the same

Please have a look at the program 'BALVST03_GRID' (or any program starting with 'BALV*'for that matter)to understand how TOP_OF_PAGE has been called,

See the smaple 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.

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

there are some more sample codes... check the below link for the above code also...

0 Kudos

Hi Naveen,

I had used the ame statements like what u told.But i was not able to see any thing in the Header.I am getting Empty Space in the Top of the ALV Grid.

Can u tell me what's the problem?

Thanks,

Gopi.

0 Kudos

can u paste your code plz...

0 Kudos

HI Naveen ,

Here is the code.

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


*ALV Header declarations

1.)data: t_header type slis_t_listheader,

i_header_str type slis_listheader,

t_line like i_header_str-info.

DATA: i_line_event_str TYPE slis_alv_event,

i_events TYPE slis_t_event.

2.)

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_top_of_page = 'TOP-OF-PAGE'

it_fieldcat = t_basic_fieldcatalog

it_events = I_events

TABLES

t_outtab = i_MBEWBasic_out.

3.)Form top_of_page.

i_header_str-typ = 'H'.

I_header_Str-info = 'EKKO Table Report'.

append I_header_str to t_header.

clear I_header_str.

  • Date

I_header_str-typ = 'S'.

I_header_str-key = 'Date: '.

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

sy-datum+4(2) '.'

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

append I_header_str to t_header.

clear: I_header_str.

CLEAR i_line_event_str.

i_line_event_str-name = 'TOP_OF_PAGE'.

APPEND i_line_event_str TO i_events.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_header.

  • i_logo = 'Z_LOGO'.

EndForm.

Thanks,

Gopi.

0 Kudos

Hi Naveen,

When i am Executing BALVST03_Grid i was not able to see the Header .I am getting Empty Space so what shall i do to correct this one.

Thanks,

Gopi.

0 Kudos

check this below....

same type of issue discussed before.. go through it once..

u may come up with a good solution

0 Kudos

Hi Naveen,

When i am executing the logic u wrote i am getting the header but not in the top of the ALV grid.But once the ALV grid is Displayed.Iam getting the Header when i am moving i mean when i press F3 Button(moving Back).Can u tell me why like that is there any way to change?

Thanks,

Gopi.

0 Kudos

Hi Guys,

The problem is in my program i didnot assigned v_Repid = sy-repid.

Thanks,

Gopi.

Former Member
0 Kudos

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

copy this code and just change the header which ever you want to display ..

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 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,

KK