全屏时 ALV 网格工具栏丢失

发布于 2024-11-18 16:20:03 字数 513 浏览 4 评论 0原文

我创建了一个简单的 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( ).

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( ).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

べ映画 2024-11-25 16:20:03

每个 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( ).

完整的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

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
川水往事 2024-11-25 16:20:03

当您使用 ALV 对象模型时,一开始会感到困惑。如果您在全屏模式下使用 ALV,则必须在程序中引用 GUI 状态,并在网格实例上使用 SET_SCREEN_STATUS 方法。 SAP 帮助此处对此进行了解释。

它有助于将 GUI 状态 SALV_TABLE_STANDARD 从函数组 SALV_METADATA_STATUS 复制到报告中作为起点,然后您可以删除任何不需要的函数。例如,如果将状态作为 ALV_STATUS 复制到程序中,则可以这样写:

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

如果要使用基于类的模型来设置 ALV 函数,则必须将网格对象嵌入屏幕中的自定义容器中。

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.

我恋#小黄人 2024-11-25 16:20:03

似乎您需要做的是从网格对象中获取 CL_SALV_FUNCTIONS_LIST 的实例,如下所示:

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

但是,从那里开始,您似乎需要做一些工作。我的建议:查看有关类 CL_SALV_TABLE 和 CL_SALV_FUNCTIONS_LIST 的文档(即,在事务 SE24 中显示类时单击文档按钮)。后者准确地告诉您需要做什么。

(另外,还有一点提示:将处理逻辑放在 try-catch 块中,因为如果初始化失败,您可能会捕获该异常,但继续尝试调用未实例化或未初始化的类上的方法)。

Seems what you need to do is get an instance of CL_SALV_FUNCTIONS_LIST from your grid object like so:

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

But, from there, it seems you need to do a bit or work. My advice: Look at the documentation on classes CL_SALV_TABLE and CL_SALV_FUNCTIONS_LIST (that is, click the documentation button when you display the class in transaction SE24). The latter tells you exactly what you need to do.

(Also, a little hint: Put your processing logic inside the try-catch block, because if the initialization fails, you might catch that exception but go on to try call a method on an uninstantiated or uninitialized class).

浅笑依然 2024-11-25 16:20:03
  • 将客户容器添加到您的 gui
  • 创建类 cl_gui_custom_container 的对象并提供容器的名称
  • 创建类 cl_gui_alv_grid 的实例并提供自定义容器对象
  • 使用方法 set_table_for_first_display

这将显示一个包含所有按钮的工具栏。您可以使用 set_table_for_first_display 方法的 IT_TOOLBAR_​​EXCLUDING 参数来控制工具栏中要显示的按钮。

  • add a customer container to your gui
  • create an object of the class cl_gui_custom_container and supply the name of your container
  • create an instance of the class cl_gui_alv_grid and supply the custom container object
  • use the method set_table_for_first_display

this will display a toolbar with all buttons. you can control which buttons you want in the toolbar with the IT_TOOLBAR_EXCLUDING parameter to the set_table_for_first_display method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文