WDA基础十二:FREE PROGRAM SH (WDA TREE)
一个需要用TREE展示搜索帮助的需求:
1.创建WDA程序:ZCATEGORY
2.Component Controller中添加节点:
(说明,此节点仅在搜索帮助程序中使用,可以不用interface node)
3.传入参数结构:
4.传出参数结构:
(取tree结构中的部分字段)
5.在Implemented Interfaces 中加入IWD_VALUE_HELP 窗口:WD_VALUE_HELP
激活全部程序。
6.在Component Controller属性中加入:
VALUE_HELP_LISTENER public ref to IF_WD_VALUE_HELP_LISTENER
方法SET_VALUE_HELP_LISTENER中实现获取传入参数
METHOD set_value_help_listener .
DATA:gs_attr TYPE wdr_context_attribute_info.
DATA:lr_attr TYPE REF TO if_wd_context_element,
gv_name TYPE string.
DATA lo_nd_attr TYPE REF TO if_wd_context_node.
DATA lo_el_attr TYPE REF TO if_wd_context_element.
DATA ls_attr TYPE wd_this->element_attr.
DATA:lr_node TYPE REF TO if_wd_context_node,
lr_father TYPE REF TO if_wd_context_element.
wd_this->value_help_listener = listener.
gs_attr = listener->f4_attribute_info.
lr_attr ?= listener->f4_context_element.
CLEAR:ls_attr. CASE gs_attr-name.
WHEN 'ZZSYMP_CODE'.
ls_attr-katalogart = 'Z1'.
gv_name = 'ZZSYMP_GROU'.
lr_attr->get_attribute(
EXPORTING
name = 'NUMBER_INT'
IMPORTING
value = wd_this->flag ).
lr_node = lr_attr->get_node( ).
CHECK lr_node IS BOUND.
lr_father = lr_node->get_parent_element( ).
CHECK lr_father IS BOUND.
lr_father->get_attribute(
EXPORTING
name = 'SALES_ORG'
IMPORTING
value = ls_attr-sales_org ).
WHEN 'SYMPTOMS_CODE' .
ls_attr-katalogart = 'Z1'.
gv_name = 'SYMPTOMS_CODE_G'.
lr_attr->get_attribute(
EXPORTING
name = 'SALES_ORG'
IMPORTING
value = ls_attr-sales_org ).
WHEN 'ZZZSYMPTOMSCODE'.
ls_attr-katalogart = 'Z1'.
gv_name = 'ZZZSYMPTOMSGROUP'. ls_attr-sales_org = zcl_otr=>gv_sales_org.
WHEN 'DEFECT_CODE'.
ls_attr-katalogart = 'Z2'.
gv_name = 'SYMPTOMS_CODE_G'.
lr_attr->get_attribute(
EXPORTING
name = 'SALES_ORG'
IMPORTING
value = ls_attr-sales_org ).
WHEN 'REPAIR_CODE'.
ls_attr-katalogart = 'Z3'.
gv_name = 'SYMPTOMS_CODE_G'.
lr_attr->get_attribute(
EXPORTING
name = 'SALES_ORG'
IMPORTING
value = ls_attr-sales_org ).
WHEN 'ZZSECTIONCODE'.
ls_attr-katalogart = 'Z5'.
gv_name = 'SYMPTOMS_CODE_G'.
lr_attr->get_attribute(
EXPORTING
name = 'SALES_ORG'
IMPORTING
value = ls_attr-sales_org ).
WHEN 'ZZAFLD00002V'.
ls_attr-katalogart = 'Z6'.
gv_name = 'SYMPTOMS_CODE_G'.
lr_attr->get_attribute(
EXPORTING
name = 'SALES_ORG'
IMPORTING
value = ls_attr-sales_org ).
WHEN OTHERS.
EXIT.
ENDCASE. lr_attr->get_attribute(
EXPORTING
name = gv_name
IMPORTING
value = ls_attr-codegr ). lo_nd_attr = wd_context->get_child_node( name = wd_this->wdctx_attr ).
lo_el_attr = lo_nd_attr->get_element( ).
lo_el_attr->set_static_attributes(
static_attributes = ls_attr ). ENDMETHOD.
READ_FOLDER
ZGRTREE Importing ZGRTREE
RESULT Returning ZGRTREET
METHOD read_folder.
DATA lo_nd_attr TYPE REF TO if_wd_context_node.
DATA lo_el_cate TYPE REF TO if_wd_context_element.
DATA lt_cate TYPE wd_this->elements_cate.
DATA ls_cate TYPE wd_this->element_cate.
DATA:gt_zgrtext TYPE TABLE OF zgrtext,
gw_zgrtext LIKE LINE OF gt_zgrtext. SELECT a~sales_org
a~zcode_catalog
a~zprod_category
a~zscode_id AS code
b~kurztext
INTO CORRESPONDING FIELDS OF TABLE gt_zgrtext
FROM ziriscode_config AS a
INNER JOIN qpct AS b
ON a~zcode_catalog = b~katalogart
AND a~zprod_category = b~codegruppe
AND a~zscode_id = b~code
WHERE a~sales_org = zgrtree-sales_org
AND a~zcode_catalog = zgrtree-zcode_catalog
AND a~zprod_category = zgrtree-zprod_category
AND a~zfcode_id = zgrtree-name
AND b~sprache = sy-langu. SORT gt_zgrtext.
DELETE ADJACENT DUPLICATES FROM gt_zgrtext COMPARING ALL FIELDS.
LOOP AT gt_zgrtext INTO gw_zgrtext.
ls_cate-name = gw_zgrtext-code.
ls_cate-path = zgrtree-name && '/' && gw_zgrtext-code.
ls_cate-PARENT_PATH = zgrtree-name.
ls_cate-text = gw_zgrtext-kurztext.
ls_cate-is_expanded = abap_false.
ls_cate-is_leaf = abap_true.
ls_cate-sales_org = gw_zgrtext-sales_org.
ls_cate-zcode_catalog = gw_zgrtext-zcode_catalog.
ls_cate-zprod_category = gw_zgrtext-zprod_category.
APPEND ls_cate TO lt_cate.
ENDLOOP. RESULT = lt_cate. ENDMETHOD.
BROWSER ->TREE_BY_KEY_COL.CATE
onSelect->SELECT
MIME_TYPE->TREE_BY_KEY_COL.CATE.TEXT
BROWSER_NAME->childrenLoaded
->expanded
->isLeaf
->parentKey->TREE_BY_KEY_COL.CATE.PARENT_PATH
->rowKey ->TREE_BY_KEY_COL.CATE.PATH
onLoadChildren->LOAD_FOLDER
BROWSER_NAME_INPUT->TREE_BY_KEY_COL.CATE.NAME
WDDOINIT:
METHOD wddoinit .
DATA lo_nd_cate TYPE REF TO if_wd_context_node.
DATA lt_cate TYPE wd_this->elements_cate.
DATA ls_cate TYPE wd_this->element_cate.
DATA:gt_zgrtext TYPE TABLE OF zgrtext,
gw_zgrtext LIKE LINE OF gt_zgrtext.
lo_nd_cate = wd_context->get_child_node( name = wd_this->wdctx_cate ).
DATA lo_nd_attr TYPE REF TO if_wd_context_node.
DATA lo_el_attr TYPE REF TO if_wd_context_element.
DATA ls_attr TYPE wd_this->element_attr. lo_nd_attr = wd_context->get_child_node( name = wd_this->wdctx_attr ).
lo_el_attr = lo_nd_attr->get_element( ).
lo_el_attr->get_static_attributes(
IMPORTING
static_attributes = ls_attr ). SELECT a~zfcode_id AS codegr
a~sales_org
a~zcode_catalog
a~zprod_category
b~kurztext AS kurztext
INTO CORRESPONDING FIELDS OF TABLE gt_zgrtext
FROM ziriscode_config AS a
INNER JOIN qpct AS b
ON a~zcode_catalog = b~katalogart
AND a~zprod_category = b~codegruppe
AND a~zfcode_id = b~code
WHERE a~sales_org = ls_attr-sales_org
AND a~zcode_catalog = ls_attr-katalogart
AND a~zprod_category = ls_attr-codegr
AND b~sprache = sy-langu.
SORT gt_zgrtext.
DELETE ADJACENT DUPLICATES FROM gt_zgrtext COMPARING ALL FIELDS.
LOOP AT gt_zgrtext INTO gw_zgrtext.
ls_cate-name = gw_zgrtext-codegr.
ls_cate-path = gw_zgrtext-codegr.
ls_cate-text = gw_zgrtext-kurztext.
ls_cate-is_expanded = abap_false.
ls_cate-is_leaf = abap_false.
ls_cate-sales_org = gw_zgrtext-sales_org.
ls_cate-zcode_catalog = gw_zgrtext-zcode_catalog.
ls_cate-zprod_category = gw_zgrtext-zprod_category.
APPEND ls_cate TO lt_cate.
ENDLOOP.
lo_nd_cate->bind_table( new_items = lt_cate set_initial_elements = abap_true ). ENDMETHOD.
METHOD onactionselect .
DATA:lr_context TYPE REF TO if_wd_context_element.
DATA lo_nd_grcode TYPE REF TO if_wd_context_node.
DATA lo_el_grcode TYPE REF TO if_wd_context_element.
DATA ls_grcode TYPE wd_this->element_grcode.
DATA:gw_code TYPE zgrtree. CLEAR:ls_grcode,gw_code. lr_context = wdevent->get_context_element( name = 'NEW_LEAD_SELECTION' ).
lr_context->get_static_attributes(
IMPORTING
static_attributes = gw_code ). lo_nd_grcode = wd_context->get_child_node( name = wd_this->wdctx_grcode ).
lo_el_grcode = lo_nd_grcode->get_element( ).
ls_grcode-sales_org = gw_code-sales_org.
ls_grcode-zcode_catalog = gw_code-zcode_catalog.
ls_grcode-zprod_category = gw_code-zprod_category.
ls_grcode-code = gw_code-name.
ls_grcode-kurztext = gw_code-text. IF wd_comp_controller->flag <> ''.
ls_grcode-kurztext = wd_comp_controller->flag.
ls_grcode-zcode_catalog = ''.
ENDIF. lo_el_grcode->set_static_attributes(
static_attributes = ls_grcode ). wd_comp_controller->fire_vh_data_selected_evt( ).
wd_comp_controller->value_help_listener->close_window( ).
ENDMETHOD.
METHOD onactionload_folder.
DATA componentcontroller_ref TYPE REF TO ig_componentcontroller.
* data folder_entries type wdr_example_mime_entry_tab.
DATA folder_entries TYPE TABLE OF zgrtree.
DATA url_path TYPE string.
DATA element TYPE REF TO if_wd_context_element.
DATA context_node TYPE REF TO if_wd_context_node.
DATA:gs_node TYPE zgrtree. * Get URL Path of folder to read
element = wd_context->path_get_element( path ).
element->get_attribute( EXPORTING name = 'PATH'
IMPORTING value = url_path ).
element->set_attribute( EXPORTING name = 'CHILDREN_LOADED'
value = abap_true ). element->get_static_attributes(
IMPORTING
static_attributes = gs_node ). * Read folder by calling method of the component controller
context_node = wd_context->get_child_node( 'CATE' ).
componentcontroller_ref = wd_this->get_componentcontroller_ctr( ). folder_entries = componentcontroller_ref->read_folder( gs_node ). * Append new lines
context_node->bind_table( new_items = folder_entries
set_initial_elements = abap_false ). ENDMETHOD.
在使用组件的程序中,添加组件:CODE ZCATEGORY Table with Tree
在Component Controller中添加程序的组件引用
定义属性:
VALUE_HELP_LISTENER ref to IF_WD_VALUE_HELP_LISTENER
新建方法:
CODE 1 Event Handler VH_DATA_SELECTED INTERFACECONTROLLER CODE
方法中对传出参数处理:
METHOD code .
DATA lo_nd_grcode TYPE REF TO if_wd_context_node.
DATA lo_el_grcode TYPE REF TO if_wd_context_element.
DATA ls_grcode TYPE wd_this->element_grcode.
DATA lo_nd_l_so_header_n TYPE REF TO if_wd_context_node.
DATA lo_el_l_so_header_n TYPE REF TO if_wd_context_element.
DATA ls_l_so_header_n TYPE wd_this->element_l_so_header_n.
DATA lv_symptoms_code TYPE wd_this->element_l_so_header_n-symptoms_code.
DATA lo_nd_t_so_item_n TYPE REF TO if_wd_context_node.
DATA lt_t_so_item_n TYPE wd_this->elements_t_so_item_n.
DATA ls_t_so_item_n TYPE wd_this->element_t_so_item_n.
DATA:lv_name TYPE string,
lv_no TYPE I. * navigate from <CONTEXT> to <GRCODE> via lead selection
lo_nd_grcode = wd_context->get_child_node( name = wd_this->wdctx_grcode ).
lo_el_grcode = lo_nd_grcode->get_element( ). lo_el_grcode->get_static_attributes(
IMPORTING
static_attributes = ls_grcode ). "动态确定返回参数赋值
CASE ls_grcode-zcode_catalog.
WHEN 'Z1'.
lv_name = `SYMPTOMS_CODE`.
WHEN 'Z2'.
lv_name = `DEFECT_CODE`.
WHEN 'Z3'.
lv_name = `REPAIR_CODE`.
WHEN 'Z5'.
lv_name = `ZZSECTIONCODE`.
WHEN 'Z6'.
lv_name = `ZZAFLD00002V`.
WHEN ''."项目
SHIFT ls_grcode-kurztext LEFT DELETING LEADING ''.
lv_no = ls_grcode-kurztext.
WHEN OTHERS.
ENDCASE. IF ls_grcode-zcode_catalog <> ''.
lo_nd_l_so_header_n = wd_context->get_child_node( name = wd_this->wdctx_l_so_header_n ).
lo_el_l_so_header_n = lo_nd_l_so_header_n->get_element( ).
lo_el_l_so_header_n->set_attribute(
name = lv_name"`SYMPTOMS_CODE`
value = ls_grcode-code ).
ELSE.
lo_nd_t_so_item_n = wd_context->path_get_node( path = `L_SO_HEADER_N.T_SO_ITEM_N` ).
lo_nd_t_so_item_n->get_static_attributes_table( IMPORTING table = lt_t_so_item_n ).
LOOP AT lt_t_so_item_n INTO ls_t_so_item_n WHERE number_int = lv_no.
ls_t_so_item_n-zzsymp_code = ls_grcode-code.
MODIFY lt_t_so_item_n FROM ls_t_so_item_n.
ENDLOOP. lo_nd_t_so_item_n->bind_table( new_items = lt_t_so_item_n set_initial_elements = abap_true ). ENDIF. ENDMETHOD.
给节点确定搜索帮助
如果是select option:
DATA lo_so_api TYPE REF TO if_wd_controller.
DATA lo_so_cmp TYPE REF TO if_wd_component.
DATA lo_so_cmp_usg_tc TYPE REF TO if_wd_component_usage_group.
DATA lo_so_cmp_usg_emp TYPE REF TO if_wd_component_usage_group.
lo_so_api = wd_this->m_wd_select_options->wd_get_api( ).
lo_so_cmp = lo_so_api->get_component( ).
"门店搜索帮助
lo_so_cmp->remove_cmp_usage_group( 'GROUP' ).
lo_so_cmp_usg_tc = lo_so_cmp->create_cmp_usage_group(
name = 'GROUP'
used_component = 'ZGROUP' ).
lt_range_table =
wd_this->m_handler->create_range_table(
i_typename = 'ZSO_SYMPTOMS_CODE' ).
* add a new field to the selection
wd_this->m_handler->add_selection_field(
i_id = 'SYMPTOMS_CODE'
i_description = zcl_otr=>get_text( 'ZCRM/SYMCODE' )"lv_value
i_value_help_type = 'APPLDEV'
i_value_help_id = 'GROUP'
* i_within_block = 'SELS'
it_result = lt_range_table
i_read_only = read_only ).
GROUP是程序添加的组件
效果:
WDA基础十二:FREE PROGRAM SH (WDA TREE)的更多相关文章
- Bootstrap <基础十二>下拉菜单(Dropdowns)
Bootstrap 下拉菜单.下拉菜单是可切换的,是以列表格式显示链接的上下文菜单.这可以通过与 下拉菜单(Dropdown) JavaScript 插件 的互动来实现. 如需使用下列菜单,只需要在 ...
- Java基础十二--多态是成员的特点
Java基础十二--多态是成员的特点 一.特点 1,成员变量. 编译和运行都参考等号的左边. 覆盖只发生在函数上,和变量没关系. Fu f = new Zi();System.out.println( ...
- 玩转Django2.0---Django笔记建站基础十二(Django项目上线部署)
第十二章 Django项目上线部署 目前部署Django项目有两种主流方案:Nginx+uWsGI+Django或者Apache+uWSGI+Django.Nginx作为服务器最前端,负责接收浏览器的 ...
- WDA基础十:OVS搜索帮助的使用
对于WDA来说,常用的搜索帮助有OVS,标准SH,Interface view等.今天来说说两种常用的OVS的使用: 一:普通字段,表字段的搜索帮助(在创建节点的时候指定搜索帮助OVS,或者后面加上去 ...
- WDA基础十四:ALV字段属性配置表
ALV配置表管理 一.字段属性配置表 对于可编辑的ALV不用这个,尽可能多的设置一些控制: 单元格类型:默认A,特殊选择 ZLYE_TYPE E A 1 ...
- WDA基础十八:Select option配置
为了省代码...为了方便管理WDA的查询条件... 首先建配置表: 说明: 上面的KEY基本都是维护的维度,可以根据销售组织,根据用户组,根据组件,根据SELECT OPTION的不同...等等,可以 ...
- WDA基础十六:ALV的颜色
这里介绍三种类型的颜色:列的背景色,单元格的背景色,单元格文本的颜色. 1.给ALV结构添加颜色控制字段: 三个字段都是同一类型:WDY_UIE_LIBRARY_ENUM_TYPE COL_BACKG ...
- WDA基础十五:POPUP WINDOW
1.组件控制器定义属性: 2.实现popup方法: METHOD stock_popup . DATA: l_cmp_api TYPE REF TO if_wd_component, l_window ...
- 玩转Django2.0---Django笔记建站基础十(二)(常用的Web应用程序)
10.3 CSRF防护 CSRF(跨站请求伪造)也成为One Click Attack或者Session Riding,通常缩写为CSRF或者XSRF,是一种对网站的恶意利用,窃取网站的用户信息来制作 ...
随机推荐
- DownAlbum:Chrome的pinterest批量下载插件
一.DownAlbum安装 二.DownAlbum使用 点击DownAlbum图标. 选择Normal. 会出现一个加载的弹窗,等待片刻会打开一个新的窗口. 按Ctrl+S,即可保存相册所有图片. 图 ...
- Facebook ads_Business Manager
xmind 下载链接
- 【MySQL】【一】shell
进入MySQL:mysql -u root -p 查看当前数据库下所有库:mysql> show databases; 切换到某库:mysql> use sys; 查看sys库下所有表:m ...
- CSS--外发光与内阴影
外阴影:box-shadow: X轴 Y轴 Rpx color; 属性说明(顺序依次对应): 阴影的X轴(可以使用负值) 阴影的Y轴(可以使用负值) 阴影模糊值(大小) 阴影的 ...
- Codeforces 746 G. New Roads
题目链接:http://codeforces.com/contest/746/problem/G mamaya,不知道YY了一个什么做法就这样过去了啊 2333 首先我显然可以随便构造出一棵树满足他所 ...
- win10上安装keras
下载Anaconda https://www.anaconda.com/ 点击进入下载界面 选择Windows版本64位,python3.7 下载完成后 ,双击安装 等待安装完成! 安装MinGW包, ...
- DataGrip激活码
引言: 网上有有很多datagirp的激活码,但是经过尝试很多都失效了,找了半天终于 找到了一个可用的激活码! 1. 激活码 适用版本: DataGrip2018.2.3,2018.1.1,其他版本没 ...
- np.zeros
np.zeros构造一个全部由0组成的矩阵 用法:zeros(shape, dtype = float, order = 'C') 参数: shape:形状 dtype类型: t ,位域,如t4代表4 ...
- [osg]OSG使用更新回调来更改模型
使用回调类实现对场景图形节点的更新.本节将讲解如何使用回调来实现在每帧的更新遍历(update traversal)中进行节点的更新. 回调概览 用户可以使用回调来实现与场景 ...
- Utunbu常见问题
关于Ubuntu中Could not get lock /var/lib/dpkg/lock解决方案 https://blog.csdn.net/u011596455/article/details/ ...