Web Dynpro for ABAP(12):Input Help

3.17Input Help

Search Help

Web Dynpro ABAP Framework提供两种方式Search Help;

1. ABAP Dictionary Search Help;

2. OVS Value Help;

OVS使用Component:WDR_OVS实现,通过Component Usage引入;

OVS使用四个阶段:

1.PHASE_INDICATOR = IF_WD_OVS=>CO_PHASE_0

配置OVS,窗口标题,输出表列名;

2.PHASE_INDICATOR = IF_WD_OVS=>CO_PHASE_1

配置OVS使用到选择selection fields结构,初始化可选值;

3.PHASE_INDICATOR = IF_WD_OVS=>CO_PHASE_2

设置查询条件;

4.PHASE_INDICATOR = IF_WD_OVS=>CO_PHASE_3

显示查询结果;

示例:

Component:WDR_TEST_DDIC_SHLP

 

自定义Search Help

实现接口Component:IWD_VALUE_HELP;

示例:

1.创建Component:Z_USER_HLP;

2.双击Component,选择Implemented interfaces:IWD_VALUE_HELP;

 

3.创建Component接口Context节点;

 

4.Context节点:NODE_HLP,选择Interface Node。这个作为Search Help帮助选择后返回值结构。Attribute:CAR_ID,Type:Char3。Attribute:CAR_DESC,Type:CHAR20;

 

5.创建Attributes,LO_LISTENER,Type:IF_WD_VALUE_HELP_LISTENER;

 

6.使用IWD_VALUE_HELP接口,会生成Events,VH_WINDOW_CLOSED,VH_VINDOW_OPENED;

 

7.使用IWD_VALUE_HELP接口,会生成Methods:SET_VALUE_HELP_LISTENER;

根据在View选择的值设置描述,也可以不用。

示例:

 DATA:lo_node TYPE REF TO if_wd_context_node.
  DATA:ls_hlp TYPE wd_this->element_node_hlp.

  "保存listener
  wd_this->lo_listener = listener.

  lo_node = wd_context->get_child_node( wd_this->wdctx_node_hlp ).
  lo_node->get_static_attributes( IMPORTING static_attributes = ls_hlp ).

  SELECT SINGLE carrname INTO ls_hlp-car_desc FROM scarr
    WHERE carrid = ls_hlp-car_id.
  IF sy-subrc = 0.
    lo_node->set_static_attributes( ls_hlp ).
  ENDIF

8. 创建VIEW:MAIN,创建Context节点,NODE:NODE_TAB_HLP,保存数据表:SCARR中可供选择的信息;

 

9.创建Element:TABLE,绑定Context节点NODE_TAB_HLP;

创建Button:CLOSE,设置按钮Action: CLOSE事件;

10.实现VIEW:MAIN中WDDOINIT方法,初始化Table节点显示数据;

示例代码:

  DATA:lo_node TYPE REF TO if_wd_context_node.
  DATA:lt_scarr TYPE wd_this->elements_node_tab_hlp.

  lo_node = wd_context->get_child_node( wd_this->wdctx_node_tab_hlp ).
  SELECT * INTO TABLE lt_scarr FROM scarr.
  lo_node->bind_table( lt_scarr ). 

11.实现Action:CLOSE方法;

示例代码:

  DATA:lo_node TYPE REF TO if_wd_context_node.
  DATA:ls_scarr TYPE wd_this->element_node_tab_hlp.
  DATA:ls_hlp TYPE wd_this->element_node_hlp.
  DATA:lt_set TYPE wdr_context_element_set.
  DATA:lo_element TYPE REF TO if_wd_context_element.

  lo_node = wd_context->get_child_node( wd_this->wdctx_node_tab_hlp ).
  lt_set = lo_node->get_selected_elements( ).
  READ TABLE lt_set INTO lo_element INDEX 1.
  IF sy-subrc = 0.
    "将选择行值设置到接口node
    lo_element->get_static_attributes( IMPORTING static_attributes = ls_scarr ).
    lo_node = wd_context->get_child_node( wd_this->wdctx_node_hlp ).
    ls_hlp-car_id = ls_scarr-carrid.
    ls_hlp-car_desc = ls_scarr-carrname.
    lo_node->set_static_attributes( ls_hlp ).
  ENDIF.
  "关闭选择窗口
  wd_comp_controller->lo_listener->close_window( ). 

12.创建Component: Z_TEST_WDA992,使用自定义Search Help的Component;

 

13.ComponentController使用Components:Z_USER_HLP;

 

14.方式1:创建NODE_HLP,结构和接口节点一致。用来接收Components:Z_USER_HLP的接口节点传过来数据;

在Component Usages中,找到Z_USER_HLP,找到INTERFACECONTROLLER_USAGE,定义接口NODE节点和COMPONENTCONTROLLER之间Mapping关系;

 

方式2:这里应该也可以直接使用Controller Usage,将INTERFACECONTROLLER的NODE_HLP节点拖过来,这样就不用创建NODE_HLP;

 

15.创建VIEW:MAIN;

创建Elements:InputField,绑定Context:CAR_ID;

创建Elements:TextView,绑定Context:CAR_DESC;

 

16.设置Context节点,CAR_ID;

设置Input Help Mode:Freely Programmed;

设置Input Help Component Usage:Z_USER_HLP;

17.创建Application,Test执行显示效果,点击帮助,显示我们自定义帮助页面;

 

 

 

Search Help & Select Options

Component: WDR_SELECT_OPTIONS,可以实现search help;

接口IF_WD_SELECT_OPTIONS方法:

CHECK_ALL_SELECTION_FIELDS,检查所有selection fields值;

RESET_SELECTION_FIELD,重置selection field;

RESET_ALL_SELCTIONS_FIELDS,重置所有selection field;

示例Component:WDR_TEST_SELECT_OPTIONS

 

Proposals for InputFields

InputFields框输入Suggest,感觉其实就是使用DDIC的Search Help;

1. InputField.valueSuggest property to TRUE;

2. bind the value of the valueSuggest property to an existing context attribute with an ABAP Dictionary type;

3. activate the application parameter WDALLOWVALUESUGGEST;

4. deactivate the Accessibility mode;

示例Component:DEMO_VALUE_SUGGEST

posted @ 2022-06-11 11:12  渔歌晚唱  阅读(123)  评论(0编辑  收藏  举报