简体   繁体   English

cl_salv_table 的应用程序工具栏中的自定义按钮?

[英]Custom button in application toolbar of cl_salv_table?

I am making a report by using cl_salv_table , and I want to make a button on toolbar of the ALV grid which will show a predefined popup.我正在使用cl_salv_table制作报告,并且我想在 ALV 网格的工具栏上制作一个按钮,该按钮将显示预定义的弹出窗口。

I was able to make a button on the toolbar and set the "Functional code" as details, and I saw in the debug mode that on clicking the button the "sy-ucomm" is set to details but it is not going the case loop.我能够在工具栏上创建一个按钮并将“功能代码”设置为详细信息,并且我在调试模式下看到单击该按钮时“sy-ucomm”设置为详细信息,但它不会进行案例循环.

Any help or suggestion would be appreciated.任何帮助或建议将不胜感激。

请查看程序 SALV_DEMO_TABLE_SELECTIONS 如何正确实现事件处理程序,基本上 lcl_handle_events 类中的 on_user_command 方法就是您要寻找的。

First of all you should have SALV grid on a screen with container:首先,您应该在带有容器的屏幕上有 SALV 网格:

try.
    cl_salv_table=>factory(
      exporting
        r_container    = gr_container
        container_name = 'CONTAINER'
      importing
        r_salv_table   = gr_table
      changing
        t_table        = gt_outtab ).
  catch cx_salv_msg.                                "#EC NO_HANDLER
endtry.

Then all functions should be enabled:然后应该启用所有功能:

lr_functions = gr_table->get_functions( ).
lr_functions->set_all( gc_true ).

Finally you add own function like this:最后,您添加自己的函数,如下所示:

include <icon>.
try.
  lr_functions->add_function(
    name     = 'MYFUNCTION'
    icon     = CONV string( icon_complete )
    text     = `My function`
    tooltip  = `My custom function`
    position = if_salv_c_function_position=>right_of_salv_functions ).
  catch cx_salv_existing cx_salv_wrong_call.
endtry.

The next significant step is to create on_user_command event handler either in the same class or in separate handler class:下一个重要步骤是在同一类或单独的处理程序类中创建on_user_command事件处理程序:

data: gr_events type ref to lcl_handle_events.
set handler gr_events->on_user_command for lr_events.

The final thing is the handler method implementation which will do actual function work最后一件事是处理程序方法的实现,它将执行实际的功能工作

class lcl_handle_events implementation.
  method on_user_command.
    message |Function { e_salv_function } is fired| TYPE 'I'.
  endmethod.            
endclass.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM