ALV网格缺少工具栏

Jor*_*inB 5 sap abap

我正在SAP中创建一个简单的ALV网格.到目前为止,我已经能够用我的数据填充网格,并在选择屏幕后显示网格没问题.我没有将网格添加到自定义屏幕上的自定义容器中.只需查看网格全屏.

我的问题是 - 我是否需要设置alv网格对象的属性才能查看通常位于网格顶部的工具栏,其中包含用于过滤,排序等的按钮?

到目前为止,这就是我所拥有的:

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( ).
Run Code Online (Sandbox Code Playgroud)

任何SAP noob的帮助将不胜感激.

Est*_*sti 7

每个ALV函数都在Simple ALV中作为单独的CLASS实现,因此您必须单独处理它们.您不需要自定义控件.

要添加工具栏:

data: lr_func TYPE REF TO CL_SALV_FUNCTIONS_LIST.
"Functions
lr_func = gr_alv->get_functions( ).
lr_func->set_all( ).
Run Code Online (Sandbox Code Playgroud)

完整的ALV显示:

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
Run Code Online (Sandbox Code Playgroud)

  • 值得注意的是,例如,如果您不想要所有导出选项,还有其他方法可以设置较小的工具栏功能集。**SET_GROUP_SORT** 用于所有排序选项,**SET_PRINT** 用于打印。主要是不言自明的。 (2认同)