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 GRID: top-of-list event

Former Member
0 Kudos

I use a top-of-list event to print the selection parameters of ALV report (using REUSE_ALV_GRID_DISPLAY).

In the output I can see the top, but the list is hidden, because the top is too large.

I must enlarge the list with mouse.

Can I fix the height of the list or of the top to see togheter in the output ?

Thnks a lot.

Claudia

1 ACCEPTED SOLUTION

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


 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.

 

Reward points if it is usefull ....

Girish

7 REPLIES 7

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


 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.

 

Reward points if it is usefull ....

Girish

0 Kudos

Thank you, I know but I Have very large top-of-page and I can't see it.

I found some SAP Notes to apply.

Thanks a lot.

Former Member
0 Kudos

Check

RSDEMO_EASY_SPLITTER_CONTROL Program RSDEMO_EASY_SPLITTER_CONTROL

RSDEMO_SPLITTER_CONTROL Program RSDEMO_SPLITTER_CONTROL

If you are saying about the Grid Title then set as below

DATA: lv_date TYPE c LENGTH 10 ,

lv_time TYPE c LENGTH 8 ,

lv_text TYPE string.

  • Set table for First Display

WRITE sy-datum TO lv_date DD/MM/YYYY.

WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.

CONCATENATE text-033 text-034 lv_date text-035 lv_time INTO lv_text RESPECTING BLANKS.

gs_layo-grid_title = lv_text.

<b> gs_layo-smalltitle = 'X' .</b>

IF gs_variant-report IS INITIAL.

gs_variant-report = sy-repid.

ENDIF.

IF NOT p_layout IS INITIAL.

gs_variant-variant = p_layout.

ENDIF.

CALL METHOD go_grid->set_table_for_first_display

EXPORTING

is_variant = gs_variant

i_save = gc_save

i_default = abap_true

is_layout = gs_layo

CHANGING

it_outtab = gt_final[]

it_fieldcatalog = gt_fcat.

Rewards if useful..................

Minal

Message was edited by:

Minal Nampalliwar

0 Kudos

Thank you, I know but I use function REUSE_ALV_GRID_DISPLAY and I don't have that parameter.

I found some SAP Notes to apply.

Thanks a lot.

Former Member
0 Kudos

Hi

Please see the example program

SALV_DEMO_HIERSEQ_FORM_EVENTS



OR see this example

REPORT zsalv_demo_hierseq_form_events NO STANDARD PAGE HEADING.

TYPES: BEGIN OF g_type_s_master.

INCLUDE TYPE alv_chck.

TYPES: expand TYPE char01,

END OF g_type_s_master,

BEGIN OF g_type_s_slave.

INCLUDE TYPE alv_t_t2.

TYPES: END OF g_type_s_slave.

TYPES: BEGIN OF g_type_s_test,

amount TYPE i,

repid TYPE syrepid,

top_of_list TYPE i,

end_of_list TYPE i,

END OF g_type_s_test.

CONSTANTS: con_master TYPE lvc_fname VALUE 'ALV_CHCK',

con_slave TYPE lvc_fname VALUE 'ALV_T_T2'.

*... §5 Definition is later

CLASS lcl_handle_events_hierseq DEFINITION DEFERRED.

DATA: gs_test TYPE g_type_s_test.

DATA: gt_master TYPE STANDARD TABLE OF g_type_s_master,

gt_slave TYPE STANDARD TABLE OF alv_t_t2.

DATA: gr_hierseq TYPE REF TO cl_salv_hierseq_table.

*... §5 object for handling the events of cl_salv_table

DATA: gr_events_hierseq TYPE REF TO lcl_handle_events_hierseq.

*----


*

  • CLASS lcl_handle_events DEFINITION

*----


*

*

*----


*

CLASS lcl_handle_events_hierseq DEFINITION.

PUBLIC SECTION.

METHODS:

on_top_of_page FOR EVENT top_of_page OF cl_salv_events_hierseq

IMPORTING r_top_of_page page table_index.

ENDCLASS. "lcl_handle_events DEFINITION

*----


*

  • CLASS lcl_handle_events IMPLEMENTATION

*----


*

*

*----


*

CLASS lcl_handle_events_hierseq IMPLEMENTATION.

METHOD on_top_of_page.

DATA: lr_content TYPE REF TO cl_salv_form_element.

DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid,

lr_grid_1 TYPE REF TO cl_salv_form_layout_grid,

lr_grid_2 TYPE REF TO cl_salv_form_layout_grid,

lr_label TYPE REF TO cl_salv_form_label,

lr_text TYPE REF TO cl_salv_form_text,

l_text TYPE string.

*... create a grid

CREATE OBJECT lr_grid.

*... in the cell create header information

CONCATENATE 'TOP_OF_PAGE' text-h01 INTO l_text SEPARATED BY space.

lr_grid->create_header_information(

row = 1

column = 1

text = l_text

tooltip = l_text ).

*... add a row to the grid -> row 2

lr_grid->add_row( ).

*... in the cell create a grid

lr_grid_1 = lr_grid->create_grid(

row = 3

column = 1 ).

*... in the cell of the second grid create a label

lr_label = lr_grid_1->create_label(

row = 1

column = 1

text = 'Number of Records'

tooltip = 'Number of Records' ).

*... in the cell of the second grid create a text

lr_text = lr_grid_1->create_text(

row = 1

column = 2

text = gs_test-amount

tooltip = gs_test-amount ).

lr_label->set_label_for( lr_text ).

*... in the cell of the second grid create a label

lr_label = lr_grid_1->create_label(

row = 2

column = 1

text = 'Output Tool'

tooltip = 'Output Tool' ).

*... in the cell of the second grid create a text

lr_text = lr_grid_1->create_text(

row = 2

column = 2

text = 'Seq List'

tooltip = 'Seq List').

lr_label->set_label_for( lr_text ).

*... in the cell of the second grid create a label

lr_label = lr_grid_1->create_label(

row = 3

column = 1

text = 'Another Label'

tooltip = 'Another Label' ).

*... in the cell of the second grid create a text

l_text = text-t15.

lr_text = lr_grid_1->create_text(

row = 3

column = 2

text = 'Another Text'

tooltip = 'Another Text').

lr_label->set_label_for( lr_text ).

*... content is the top grid

lr_content = lr_grid.

*... set the content

r_top_of_page->set_content( lr_content ).

ENDMETHOD. "on_top_of_page

ENDCLASS. "lcl_handle_events IMPLEMENTATION

*----


*

  • SELECTION-SCREEN *

*----


*

SELECTION-SCREEN BEGIN OF BLOCK gen WITH FRAME.

PARAMETERS:

p_amount TYPE i DEFAULT 30.

SELECTION-SCREEN END OF BLOCK gen.

*----


*

  • START-OF-SELECTION *

*----


*

START-OF-SELECTION.

gs_test-amount = p_amount.

gs_test-repid = sy-repid.

*... §1 select data into global output table

PERFORM select_data.

*----


*

  • END-OF-SELECTION *

*----


*

END-OF-SELECTION.

PERFORM display_hierseq.

*&----


*

*& Form select_data

*&----


*

  • §1 select data into your global output table

*----


*

FORM select_data.

FIELD-SYMBOLS: -connid. "#EC *

APPEND LINES OF lt_slave TO gt_slave.

ENDLOOP.

ENDFORM. " select_data

*&----


*

*& Form display_hierseq

*&----


*

  • text

*----


*

FORM display_hierseq.

DATA:lt_binding TYPE salv_t_hierseq_binding,

ls_binding TYPE salv_s_hierseq_binding.

DATA:lr_functions TYPE REF TO cl_salv_functions_list.

DATA:lr_columns TYPE REF TO cl_salv_columns_hierseq,

lr_column TYPE REF TO cl_salv_column_hierseq.

DATA:lr_level TYPE REF TO cl_salv_hierseq_level.

*... create the binding information between master and slave

ls_binding-master = 'MANDT'.

ls_binding-slave = 'MANDT'.

APPEND ls_binding TO lt_binding.

ls_binding-master = 'CARRID'.

ls_binding-slave = 'CARRID'.

APPEND ls_binding TO lt_binding.

ls_binding-master = 'CONNID'.

ls_binding-slave = 'CONNID'.

APPEND ls_binding TO lt_binding.

*... §2 create an ALV hierseq table

TRY.

cl_salv_hierseq_table=>factory(

EXPORTING

t_binding_level1_level2 = lt_binding

IMPORTING

r_hierseq = gr_hierseq

CHANGING

t_table_level1 = gt_master

t_table_level2 = gt_slave ).

CATCH cx_salv_data_error cx_salv_not_found.

ENDTRY.

*... Functions

*... activate ALV generic Functions

lr_functions = gr_hierseq->get_functions( ).

lr_functions->set_all( abap_true ).

*... *** MASTER Settings ***

TRY.

lr_columns = gr_hierseq->get_columns( 1 ).

CATCH cx_salv_not_found.

ENDTRY.

*... set the columns technical

TRY.

lr_column ?= lr_columns->get_column( 'MANDT' ).

lr_column->set_technical( if_salv_c_bool_sap=>true ).

CATCH cx_salv_not_found. "#EC NO_HANDLER

ENDTRY.

*... set expand column

TRY.

lr_columns->set_expand_column( 'EXPAND' ).

CATCH cx_salv_data_error. "#EC NO_HANDLER

ENDTRY.

*... set items expanded

TRY.

lr_level = gr_hierseq->get_level( 1 ).

CATCH cx_salv_not_found.

ENDTRY.

lr_level->set_items_expanded( ).

*... *** GENERAL Settings ***

*... register to the events for top-of-page and end-of-page

DATA: lr_events TYPE REF TO cl_salv_events_hierseq.

lr_events = gr_hierseq->get_event( ).

CREATE OBJECT gr_events_hierseq.

SET HANDLER gr_events_hierseq->on_top_of_page FOR lr_events.

*... display the table

gr_hierseq->display( ).

ENDFORM. "display_hierseq

Reward if usefull

0 Kudos

Thank you, I know but I use function REUSE_ALV_GRID_DISPLAY and I don't have that parameter.

I found some SAP Notes to apply.

Thanks a lot.

Former Member
0 Kudos

I found some SAP Notes to apply.

Thanks a lot.

Realese 4.6 C

Note 849831 - ALV HTML header: Specified amount is ignored OK !!!!

Note 807964 - ALV OM fullscreen:Display w/o top-of-list and w/ end-of list OK !!!!

Note 511749 - ALV fullscreen: Specifying heights for HTML areas OK !!!