SAP ABAP Webdynpro ALV的link to action的实现方法
If you include the standard webdynpro ALV component SALV_WD_TABLE into your own component, you could not directly change the ALV table column as usual. In ABAP Webdynpro an example of link to action element used in ALV looks like below. Once the column “Social Media Post ID” is clicked, it is expected our application could catch the event and implement our own event handling logic.
You could follow the steps below:
(1) Define the component usage to ALV component by double clicking your webdynpro component in SE80 and maintain the component usage in tab “Used Web Dynpro Components”
(2) Double click the INTERFACECONTROLLER_USAGE,add your own component for ALVcomponent usage. The reason for this is you need to map the context node of your own component to ALV component, so that it can know which data from your application should display.
After that it is ready for mapping the context node of your component to the context node DATA of ALV component. You can achieve it via drag and drop or right click on DATA node, and choose “Define External Mapping” from context menu. After mapping is done, you could see the mapping path displayed below.
(3) double click on your view, and insert a new element “ViewContainerUIElement”, which acts as the container for ALV interface view to be embedded.
then double click on window, right click the ViewContainerUIElement and choose “Embed View”, include the ALV interface view from drop down list.
The final settings looks like below. Now you should already see the ALV in your application UI.
Create a new method in view controller and implement the code below:
method RENDER_HYPERLINK .
DATA:
lr_alv_usage TYPE REF TO if_wd_component_usage,
lr_if_controller TYPE REF TO iwci_salv_wd_table,
lr_config TYPE REF TO cl_salv_wd_config_table,
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lt_columns TYPE salv_wd_t_column_ref,
lr_link TYPE REF TO cl_salv_wd_uie_link_to_action.
lr_alv_usage = wd_this->wd_cpuse_salv_wd_table( ).
IF lr_alv_usage->has_active_component( ) IS INITIAL.
lr_alv_usage->create_component( ).
ENDIF.
lr_if_controller = wd_this->wd_cpifc_salv_wd_table( ).
lr_config = lr_if_controller->get_model( ).
lr_config->if_salv_wd_table_settings~set_cell_action_event_enabled( abap_false ).
lr_column_settings ?= lr_config.
lt_columns = lr_column_settings->get_columns( ).
LOOP AT lt_columns ASSIGNING FIELD-SYMBOL(<column>).
CASE <column>-id.
WHEN 'INTERNAL_ID'.
CREATE OBJECT lr_link.
lr_link->set_text_fieldname( <column>-id ).
<column>-r_column->set_cell_editor( lr_link ).
WHEN OTHERS.
ENDCASE.
ENDLOOP.
endmethod.
And call it in wddomodifyview of view controller:
METHOD wddomodifyview .
CHECK first_time = abap_true.
render_hyperlink( ).
ENDMETHOD.
Note: according to sap help, the event ON_CLICK is only triggered if the method IF_SALV_WD_TABLE_SETTINGS~SET_CELL_ACTION_EVENT_ENABLED is set to FALSE Otherwise, the event ON_CELL_ACTION is triggered. (4) Create a event handler in view controller Methods tab. Choose the event name ON_CLICK from drop down list.
In the runtime, the selected item index and item value could be found in importing parameter R_PARAM:
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- OpenWRT结合tinc组自己的SDLAN
- 通过Cloudflare API更新DNS记录
- Vedastr:基于PyTorch的场景文本识别工具箱
- vue-element-admin项目关闭eslint校验
- 搞了半天,终于弄懂了TCP Socket数据的接收和发送,太难~
- 每天一个小技巧:CSS clip-path 的妙用 Clip Path分类Clippy
- 20 个值得学习的 Vue 开源项目
- 小白入门WEB前端编程,必看知识点!核心干货
- 新网站 Robots 和 SiteMap 优化
- Java代理IP池 ( Proxy Pool ) - 改进版
- Lvs+Keepalived 保障HA高可用
- 基于前端JS导出Excel文件(减轻服务端压力)
- 本机IDEA远程调试远端服务器代码
- 开源 - Java接口API授权认证与规范
- 亿及流量多级缓存 - 客户端缓存