Skip to Content
0
Former Member
Jan 05, 2009 at 03:46 PM

ALV Top Of Page on Every Page

129 Views

I've looked for an answer on this, but can't find anything so I'm asking for help. We are doing ALV without using the REUSE_ALV_DISPLAY function module. The consultants have given us a sample program,but this sample doesn't create the Top Of Page on every page like we need it to and I can't figure out how to make it do it. We need TOP with the page number displayed and it only shows on the first page. Can someone tell me how to modify this code to make TOP show on every page?

REPORT zalv_template.

*

  • -------------------------------------------------------------------------------

DATA: l_table TYPE REF TO cl_salv_table,

l_functions TYPE REF TO cl_salv_functions,

l_display TYPE REF TO cl_salv_display_settings,

l_agg TYPE REF TO cl_salv_aggregations,

l_sorts TYPE REF TO cl_salv_sorts,

l_layout TYPE REF TO cl_salv_layout,

l_column TYPE REF TO cl_salv_column_table,

l_columns TYPE REF TO cl_salv_columns_table,

l_color TYPE lvc_s_colo,

l_key TYPE salv_s_layout_key,

lr_grid TYPE REF TO cl_salv_form_layout_grid,

lr_grid_1 TYPE REF TO cl_salv_form_layout_grid,

lr_flow type ref to cl_salv_form_layout_flow,

lr_label TYPE REF TO cl_salv_form_label,

lr_text TYPE REF TO cl_salv_form_text,

  • this is the table of data that must be displayed on the report

  • - you do not need to change the existing name, it is used here as a generic name

  • l_datatab TYPE STANDARD TABLE OF csks.

l_datatab TYPE STANDARD TABLE OF PA0008.

  • FOR TESTING ONLY ************************************************

SELECT * INTO TABLE l_datatab UP TO 150 ROWS

FROM PA0008

WHERE ( TRFGR = '22' OR

TRFGR = '23' OR

TRFGR = '25' )

AND ENDDA = '99991231'.

  • this method will take the data table and convert it into gr_table

cl_salv_table=>factory( IMPORTING r_salv_table = l_table

CHANGING t_table = l_datatab ).

  • get all functions - this is the line with the icons to filter, sort,download, print etc.

l_functions = l_table->get_functions( ).

l_functions->set_all( abap_true ).

*

SY-PAGNO = 1.

PERFORM top_of_page.

  • get display settings -------------------------------------------------------------------------

l_display = l_table->get_display_settings( ).

l_display->set_striped_pattern( cl_salv_display_settings=>true ).

l_columns = l_table->get_columns( ). "sets the handle for all of the columns

**l_column ?= l_columns->get_column( 'VERAK' ).

l_column ?= l_columns->get_column( 'STVOR' ).

l_column->set_technical( if_salv_c_bool_sap=>true ).

  • to set leading zero

*l_column ?= l_columns->get_column( 'VERAK' ).

*l_column->set_leading_zero( if_salv_c_bool_sap=>true ).

  • to add the column headings --------------------------------------------------------------------

  • if you do not add headings it will be defaulted from the data dictionary

l_column ?= l_columns->get_column( 'BEGDA' ). "this will get an individual column

  • this will overwrite the data element specified in the data dictionary-------------------------

l_column->set_long_text( 'this is long text' ).

l_column->set_medium_text( 'this is medium text' ).

l_column->set_short_text( 'short text' ).

l_sorts = l_table->get_sorts( ).

l_sorts->add_sort( columnname = 'TRFGR' subtotal = abap_true ).

l_agg = l_table->get_aggregations( ).

l_agg->add_aggregation( 'ANSAL' ).

l_agg->add_aggregation( 'BET01' ).

  • l_sorts->add_sort( columnname = 'column name' sequence = 2 ). " sort descending

  • this will add the 2 icons which allow the user to change/save the layout ------------------------

l_layout = l_table->get_layout( ).

l_key-report = sy-cprog.

l_layout->set_key( l_key ).

  • allow use of defaults

l_layout->set_default( abap_true ).

l_layout->set_save_restriction( cl_salv_layout=>restrict_none ).

  • this will display the ALV screen -----------------------------------------------------------------

l_table->display( ).

&----


*& Form TOP_OF_PAGE

*

----


FORM top_of_page .

*

data: date1(12) type c,

page1(5) type c,

time1(8) type c.

create object lr_grid.

lr_grid->create_header_information( row = 1

column = 1

text = 'Arkansas Administration Statewide Information System'

tooltip = 'Arkansas Administration Statewide Information System' ).

*... in the cell [2,1] create a grid

lr_grid_1 = lr_grid->create_grid( row = 2

column = 1 ).

*... in the cell [1,1] of the second grid create a label

lr_text = lr_grid_1->create_text( row = 1

column = 1

colspan = 2

text = 'this is the title '

tooltip = ' this is the title ' ).

lr_flow = lr_grid_1->create_flow( row = 2

column = 1 ).

*

lr_label = lr_flow->create_label( text = 'Program:'

tooltip = 'Program name ' ).

lr_text = lr_flow->create_text( text = sy-cprog

tooltip = sy-cprog ).

lr_flow = lr_grid_1->create_flow( row = 3

column = 1 ).

lr_label = lr_flow->create_label( text = 'System:'

tooltip = 'System:' ).

lr_text = lr_flow->create_text( text = sy-sysid

tooltip = sy-sysid ).

lr_flow = lr_grid_1->create_flow( row = 3

column = 2 ).

lr_label = lr_flow->create_label( text = 'Client:'

tooltip = 'Client:' ).

lr_text = lr_flow->create_text( text = sy-mandt

tooltip = sy-mandt ).

lr_flow = lr_grid_1->create_flow( row = 4

column = 1 ).

WRITE: sy-datum TO date1,

sy-uzeit TO time1.

lr_label = lr_flow->create_label( text = 'Date:'

tooltip = 'Date:' ).

lr_text = lr_flow->create_text( text = date1

tooltip = date1 ).

lr_flow = lr_grid_1->create_flow( row = 4

column = 2 ).

lr_label = lr_flow->create_label( text = 'Time:'

tooltip = 'Time:' ).

lr_text = lr_flow->create_text( text = time1

tooltip = time1 ).

lr_flow = lr_grid_1->create_flow( row = 4

column = 3 ).

lr_label = lr_flow->create_label( text = 'Page:'

tooltip = 'Page:' ).

WRITE: sy-pagno TO page1.

lr_text = lr_flow->create_text( text = page1

tooltip = page1 ).

*

l_table->set_top_of_list( lr_grid ).

*

endform.