Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ALV Grid toolbar is missing in fullscreen

Tags:

toolbar

abap

alv

I've created a simple ALV grid and populated the grid with data, now the grid is displayed after the selection screen. I'm not using custom container and display the grid in full screen.

Is there a property of ALV grid object that enables toolbar with buttons filter, sort, etc, that is normally on top of the grid?

So far this is what I have:

TRY.
  cl_salv_table=>factory(
    IMPORTING
      r_salv_table   = gr_alv
    CHANGING
      t_table        = tbl_data
      ).
CATCH cx_salv_msg.
ENDTRY.

* initialize the alv settings - nothing done here for the moment.
PERFORM define_settings USING gr_alv.

* Display the ALV
gr_alv->display( ).
like image 642
JordinB Avatar asked Jul 04 '11 18:07

JordinB


2 Answers

Each ALV function is implemented as a separate CLASS in Simple ALV, so you have to handle them separately. You do not need a custom control.

In order to add the toolbar:

data: lr_func TYPE REF TO CL_SALV_FUNCTIONS_LIST.
"Functions
lr_func = gr_alv->get_functions( ).
lr_func->set_all( ).

Complete ALV display:

form display_results.

  data: ls_key        type salv_s_layout_key,

        lo_table      type ref to cl_salv_table,
        lo_cols       type ref to cl_salv_columns_table,
        lo_events     type ref to cl_salv_events_table,
        lo_funcs      type ref to cl_salv_functions_list,
        lo_layout     type ref to cl_salv_layout,
        lo_display    type ref to cl_salv_display_settings,
        lo_selections type ref to cl_salv_selections.

  try.
      call method cl_salv_table=>factory
        exporting
          list_display = abap_false
        importing
          r_salv_table = lo_table
        changing
          t_table      = gt_list.
    catch cx_salv_msg .                                 "#EC NO_HANDLER
  endtry.
  "Events
  create object go_events.
  lo_events = lo_table->get_event( ).
  set handler go_events->double_click for lo_events.

  "Layouts
  ls_key-report = sy-repid.
  lo_layout = lo_table->get_layout( ).
  lo_layout->set_key( ls_key ).
  lo_layout->set_default( abap_true ).
  lo_layout->set_save_restriction( ).
  lo_layout->set_initial_layout( p_var ).

  lo_cols = lo_table->get_columns( ).
  perform change_columns changing lo_cols.

  "Functions
  lo_funcs = lo_table->get_functions( ).
  lo_funcs->set_all( ).

  "Display Settings
  lo_display = lo_table->get_display_settings( ).
  lo_display->set_striped_pattern( abap_true ).

  "Selections
  lo_selections = lo_table->get_selections( ).
  lo_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

  lo_table->display( ).
endform.                   " DISPLAY_RESULTS
like image 90
Esti Avatar answered Sep 20 '22 05:09

Esti


This is confusing at first when you use the ALV object model. If you use the ALV in fullscreen mode you have to reference a GUI status in your program, and use the method SET_SCREEN_STATUS on your grid instance. It's explained in the SAP Help here.

It helps to copy the GUI status SALV_TABLE_STANDARD from function group SALV_METADATA_STATUS into your report as a starting point, and then you can remove any functions you don't need. For example, if you copied the status into your program as ALV_STATUS, you would write:

gr_alv->set_screen_status( report   = sy-repid
                           pfstatus = 'ALV_STATUS' ).

If you want to use the class-based model of setting up ALV functions, you have to embed the grid object in a custom container in a screen.

like image 36
nath Avatar answered Sep 22 '22 05:09

nath