WDA基础十:OVS搜索帮助的使用

对于WDA来说,常用的搜索帮助有OVS,标准SH,Interface view等。今天来说说两种常用的OVS的使用:

一:普通字段,表字段的搜索帮助(在创建节点的时候指定搜索帮助OVS,或者后面加上去)

1.创建WDA程序,双击程序组件,在使用组件界面添加OVS组件,如下图:

OVS组件名可随意定义,组件选择WDR_OVS,保存激活整个程序。

2.在需要使用的视图中,添加步骤1中定义的OVS组件:双击视图,在视图属性页签,点击新建将1中的组件添加进视图中。

定义的OVS会生成两个组件都添加进视图

3.将定义的OVS组件添加到节点属性字段的搜索帮助,如下图:

4.为OVS事件定义方法:

输入方法名,选择事件类型EVENT,在事件里F4选择前面定义的OVS事件

5.代码实现OVS搜索帮助:

method ON_OVS_OWNER .
  types:
    begin of lty_stru_input,"定义查询参数结构
      CODEGRUPPE type QCODEGRP,
    end of lty_stru_input.
  types:
    begin of lty_stru_list,"定义搜搜帮助返回结果字段列表
      CODEGRUPPE type QCODEGRP,
      CODE type QCODE,
      KURZTEXT type QTXT_CODE,
      GROUPTEXT type QKTEXTGR,
    end of lty_stru_list.

  data: ls_search_input  type lty_stru_input,
        ls_select_list   type lty_stru_list,
        lt_select_list   type standard table of lty_stru_list,
        ls_text          type wdr_name_value,
        lt_label_texts   type wdr_name_value_list,
        lt_column_texts  type wdr_name_value_list,
        lv_window_title  type string,
        lv_group_header  type string,
        lv_table_header  type string.

  DATA: ls_ORDER_QCODE type ZV_ORDER_QCODE,
        lt_ORDER_QCODE type table of  ZV_ORDER_QCODE.

  field-symbols: <ls_query_params> type lty_stru_input,
                 <ls_selection>    type lty_stru_list.

  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_g TYPE wd_this->Element_l_so_header_n-symptoms_code_g.

  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->get_attribute(
    EXPORTING
      name =  `SYMPTOMS_CODE_G`
    IMPORTING
      value = lv_symptoms_code_g ).

  case ovs_callback_object->phase_indicator.
    when if_wd_ovs=>co_phase_0.
      lv_window_title = ‘Choice Symptoms Code:‘.
      ovs_callback_object->set_configuration(
                label_texts  = lt_label_texts
                column_texts = lt_column_texts
                group_header = lv_group_header
                window_title = lv_window_title
                table_header = lv_table_header
                col_count    = 3
                row_count    = 20 ).

    when if_wd_ovs=>co_phase_1.

    when if_wd_ovs=>co_phase_2.
      select * into corresponding fields of table lt_ORDER_QCODE
      from ZV_ORDER_QCODE
      where KATALOGART = ‘Z1‘
        and CODEGRUPPE = lv_symptoms_code_g
        AND SPRACHE = SY-LANGU."ADD DEFAULT LANGU BY LY 20170113 .

      clear: lt_select_list.

      loop at lt_ORDER_QCODE into ls_ORDER_QCODE.
        ls_select_list-CODEGRUPPE = ls_ORDER_QCODE-CODEGRUPPE.
        ls_select_list-GROUPTEXT = ls_ORDER_QCODE-GROUPTEXT.
        ls_select_list-CODE = ls_ORDER_QCODE-CODE.
        ls_select_list-KURZTEXT = ls_ORDER_QCODE-KURZTEXT.

        append ls_select_list to lt_select_list.
      endloop.
      ovs_callback_object->set_output_table( output = lt_select_list ).

    when if_wd_ovs=>co_phase_3.
      if ovs_callback_object->selection is not bound.
      endif.

      assign ovs_callback_object->selection->* to <ls_selection>.
      if <ls_selection> is assigned."返回选择结果,可返回多个字段
        ovs_callback_object->context_element->set_attribute(
                               name  = `SYMPTOMS_CODE`
                               value = <ls_selection>-CODE ).
      endif.
  endcase.

endmethod.

二、select option中设置OVS

不同的是需要在SELECT OPTION中添加OVS对象:

METHOD init_select_options .
  DATA:
    lt_range_table TYPE REF TO data,
    rt_range_table TYPE REF TO data,
    read_only      TYPE abap_bool,
    typename       TYPE string,
    lv_value       TYPE string.
  DATA:
    lr_componentcontroller TYPE REF TO ig_componentcontroller,
    l_ref_cmp_usage        TYPE REF TO if_wd_component_usage.
  DATA:
    display_btn_cancel  TYPE abap_bool,
    display_btn_check   TYPE abap_bool,
    display_btn_reset   TYPE abap_bool,
    display_btn_execute TYPE abap_bool.
  DATA:gt_value_set TYPE wdy_key_value_table,
       gw_value_set TYPE wdy_key_value,
       gt_type      TYPE TABLE OF crmc_proc_type_t,
       gw_type      LIKE LINE OF gt_type.

* create the used component
  l_ref_cmp_usage = wd_this->wd_cpuse_selection( ).
  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.
* get a pointer to the interface controller of the select options
*component
  wd_this->m_wd_select_options = wd_this->wd_cpifc_selection( ).

* init the select screen
  wd_this->m_handler =
  wd_this->m_wd_select_options->init_selection_screen( ).

  "sales_org
* create a range table that consists of this new data element
  lt_range_table = wd_this->m_handler->create_range_table( i_typename = ‘CRMT_SALES_ORG‘ ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
                          i_id = ‘SALES_ORG‘
                          it_result = lt_range_table
                          i_read_only = read_only ).

* create a range table that consists of this new data element
  lt_range_table = wd_this->m_handler->create_range_table( i_typename = ‘CRMT_OBJECT_ID_DB‘ ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
                          i_id = ‘OBJECT_ID‘
                          it_result = lt_range_table
                          i_read_only = read_only ).

* create a range table PROCESS TYPE
  lt_range_table = wd_this->m_handler->create_range_table( i_typename = ‘CRMT_PROCESS_TYPE‘ ).
  "ADD DEFAULT VALUE SET
  SELECT * INTO TABLE gt_type FROM crmc_proc_type_t
    WHERE process_type IN (‘ZSO2‘,‘ZSO3‘,‘ZSO5‘)
    AND   langu        = sy-langu.
  LOOP AT gt_type INTO gw_type.
    gw_value_set-key = gw_type-process_type.
    gw_value_set-value = gw_type-p_description.
    APPEND gw_value_set TO gt_value_set.
  ENDLOOP.
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
                          i_id = ‘PROCESS_TYPE‘
                          it_result = lt_range_table
                          it_value_set = gt_value_set
                          i_read_only = read_only ).

* create a range table that consists of this new data element
  lt_range_table = wd_this->m_handler->create_range_table( i_typename = ‘BU_PARTNER‘ ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
                          i_id = ‘PARTNER‘
                          it_result = lt_range_table
                          i_read_only = read_only ).

* create a range table that consists of this new data element
  lt_range_table = wd_this->m_handler->create_range_table( i_typename = ‘CRMT_POSTING_DATE‘ ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
                          i_id = ‘POSTING_DATE‘
                          i_description = lv_value
                          it_result = lt_range_table
                          i_read_only = read_only ).

* create a range table that consists of this new data element
  lt_range_table = wd_this->m_handler->create_range_table( i_typename = ‘CRM_J_STATUS‘ ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
                          i_id = ‘STAT‘
                          it_result = lt_range_table
                          i_value_help_type = ‘OVR‘
                          i_value_help_id = ‘OVS‘
                          i_read_only = read_only ).

*End add
* adjust the global options
  wd_this->m_handler->set_global_options(
      i_display_btn_cancel  = display_btn_cancel
      i_display_btn_check   = display_btn_check
      i_display_btn_reset   = display_btn_reset
      i_display_btn_execute = display_btn_execute ).

ENDMETHOD.

然后就与前面相同:

METHOD ovs .
  CHECK i_ovs_data-m_selection_field_id EQ ‘STAT‘.

  TYPES:
    BEGIN OF lty_stru_input,
      stsma TYPE j_stsma,    "搜索条件
      estat TYPE j_estat,
      txt30 TYPE j_txt30,
    END OF lty_stru_input.
  TYPES:
    BEGIN OF lty_stru_list,
*   add fields for the selection list here
      stsma TYPE j_stsma,    "搜索条件
      estat TYPE j_estat,
      txt04 TYPE j_txt04,
      txt30 TYPE j_txt30,
    END OF lty_stru_list.

  DATA: ls_search_input TYPE lty_stru_input,
        lt_select_list  TYPE STANDARD TABLE OF lty_stru_list,
        ls_select_list  TYPE lty_stru_list,
        ls_text         TYPE wdr_name_value,
        lt_label_texts  TYPE wdr_name_value_list,
        lt_column_texts TYPE wdr_name_value_list,
        lv_window_title TYPE string,
        lv_group_header TYPE string,
        lv_table_header TYPE string,
        gt_tj30t        TYPE TABLE OF tj30t,
        gw_tj30t        LIKE LINE OF gt_tj30t.

  FIELD-SYMBOLS: <ls_query_params> TYPE lty_stru_input,
                 <ls_selection>    TYPE lty_stru_list.

  CASE i_ovs_data-m_ovs_callback_object->phase_indicator.

    WHEN if_wd_ovs=>co_phase_0.  "configuration phase, may be omitted
*   in this phase you have the possibility to define the texts,
*   if you do not want to use the defaults (DDIC-texts)

      ls_text-name = `STSMA`.  "must match a field name of search
      ls_text-value = `Status Profile`. "wd_assist->get_text( `001` ).
      INSERT ls_text INTO TABLE lt_label_texts.

      ls_text-name = `ESTAT`.  "must match a field name of search
      ls_text-value = `User Status`. "wd_assist->get_text( `001` ).
      INSERT ls_text INTO TABLE lt_label_texts.

      ls_text-name = `TXT30`.  "must match a field name of search
      ls_text-value = `Object status`. "wd_assist->get_text( `001` ).
      INSERT ls_text INTO TABLE lt_label_texts.

      ls_text-name = `STSMA`.  "must match a field in list structure
      ls_text-value = `Status Profile`. "wd_assist->get_text( `002` ).
      INSERT ls_text INTO TABLE lt_column_texts.

      ls_text-name = `ESTAT`.  "must match a field in list structure
      ls_text-value = `User Status`. "wd_assist->get_text( `002` ).
      INSERT ls_text INTO TABLE lt_column_texts.

      ls_text-name = `TXT04`.  "must match a field in list structure
      ls_text-value = `Individual status of an object`. "wd_assist->get_text( `002` ).
      INSERT ls_text INTO TABLE lt_column_texts.

      ls_text-name = `TXT30`.  "must match a field in list structure
      ls_text-value = `Object status`. "wd_assist->get_text( `002` ).
      INSERT ls_text INTO TABLE lt_column_texts.

*      lv_window_title = wd_assist->get_text( `003` ).
*      lv_group_header = wd_assist->get_text( `004` ).
*      lv_table_header = wd_assist->get_text( `005` ).

      i_ovs_data-m_ovs_callback_object->set_configuration(
                label_texts  = lt_label_texts
                column_texts = lt_column_texts
                group_header = lv_group_header
                window_title = lv_window_title
                table_header = lv_table_header
                col_count    = 4
                row_count    = 20 ).

    WHEN if_wd_ovs=>co_phase_1.  "set search structure and defaults
*   In this phase you can set the structure and default values
*   of the search structure. If this phase is omitted, the search
*   fields will not be displayed, but the selection table is
*   displayed directly.
*   Read values of the original context (not necessary, but you
*   may set these as the defaults). A reference to the context
*   element is available in the callback object.

      i_ovs_data-m_ovs_callback_object->context_element->get_static_attributes(
          IMPORTING static_attributes = ls_search_input ).
*     pass the values to the OVS component
      i_ovs_data-m_ovs_callback_object->set_input_structure(
          input = ls_search_input ).

    WHEN if_wd_ovs=>co_phase_2.
*   If phase 1 is implemented, use the field input for the
*   selection of the table.
*   If phase 1 is omitted, use values from your own context.

      IF i_ovs_data-m_ovs_callback_object->query_parameters IS NOT BOUND.
******** TODO exception handling
      ENDIF.
      ASSIGN i_ovs_data-m_ovs_callback_object->query_parameters->*
                              TO <ls_query_params>.
      IF NOT <ls_query_params> IS ASSIGNED.
******** TODO exception handling
      ENDIF.

      REFRESH:gt_tj30t.
      DATA: rt_object_id TYPE REF TO data.
      DATA:gt_file TYPE TABLE OF crmc_proc_type,
           gw_file LIKE LINE OF gt_file.
      FIELD-SYMBOLS: <process_type> TYPE table.
      rt_object_id = wd_this->m_handler->get_range_table_of_sel_field( i_id = ‘PROCESS_TYPE‘ ).
      ASSIGN rt_object_id->* TO <process_type>.
      IF <process_type> IS ASSIGNED.
        SELECT * INTO TABLE gt_file FROM crmc_proc_type
          WHERE process_type IN <process_type>
          AND process_type IN (‘ZSO2‘,‘ZSO3‘,‘ZSO5‘).
      ELSE.
        SELECT * INTO TABLE gt_file FROM crmc_proc_type WHERE process_type IN (‘ZSO2‘,‘ZSO3‘,‘ZSO5‘).
      ENDIF.
      IF gt_file IS NOT INITIAL.
        SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_select_list
          FROM tj30t FOR ALL ENTRIES IN gt_file WHERE stsma = gt_file-user_stat_proc
          AND spras = sy-langu.
      ENDIF.

*     call business logic for a table of possible values
*     lt_select_list = ???

      i_ovs_data-m_ovs_callback_object->set_output_table( output = lt_select_list ).

    WHEN if_wd_ovs=>co_phase_3.
*   apply result
      FIELD-SYMBOLS : <lt_sel_opt_result> TYPE STANDARD TABLE.

      IF i_ovs_data-m_ovs_callback_object->selection IS NOT BOUND.
******** TODO exception handling
      ENDIF.

      ASSIGN i_ovs_data-m_ovs_callback_object->selection->* TO <ls_selection>.
      IF <ls_selection> IS ASSIGNED.
        ASSIGN i_ovs_data-mt_selected_values->* TO <lt_sel_opt_result>.
        INSERT <ls_selection>-estat INTO TABLE <lt_sel_opt_result>.
*      or
*        I_OVS_DATA-m_ovs_callback_object->context_element->set_static_attributes(
*                               static_attributes = <ls_selection> ).

      ENDIF.
  ENDCASE.
ENDMETHOD.
时间: 2024-10-13 12:08:33

WDA基础十:OVS搜索帮助的使用的相关文章

POJ 2704 Pascal&#39;s Travels (基础记忆化搜索)

Pascal's Travels Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5328   Accepted: 2396 Description An n x n game board is populated with integers, one nonnegative integer per square. The goal is to travel along any legitimate path from t

Java基础十二--多态是成员的特点

Java基础十二--多态是成员的特点 一.特点 1,成员变量. 编译和运行都参考等号的左边. 覆盖只发生在函数上,和变量没关系. Fu f = new Zi();System.out.println(f.num);//是父类,答案是3 2,成员函数(非静态). 编译看左边,运行看右边. 因为成员函数存在覆盖特性. Fu f = new Zi();//f.show();输出的是子类里面的show方法 3,静态函数. 编译和运行都看左边. 静态函数不具备多态性,多态性是对象的多态性,然后静态函数不涉

Java基础十--接口

Java基础十--接口 一.接口的定义和实例 1 /* 2 abstract class AbsDemo 3 { 4 abstract void show1(); 5 abstract void show2(); 6 } 7 8 当一个抽象类中的方法都是抽象的时候,这时可以将该抽象类用 9 另一种形式定义和表示,就是 接口 interface. 10 */ 11 12 //定义接口使用的关键字不是class,是interface. 13 //interface编译后还是.class文件,其实本质

Bootstrap&lt;基础十五&gt; 输入框组

Bootstrap 支持的另一个特性,输入框组.输入框组扩展自 表单控件.使用输入框组,可以很容易地向基于文本的输入框添加作为前缀和后缀的文本或按钮. 通过向输入域添加前缀和后缀的内容,您可以向用户输入添加公共的元素.例如,可以添加美元符号,或者在 Twitter 用户名前添加 @,或者应用程序接口所需要的其他公共的元素. 向 .form-control 添加前缀或后缀元素的步骤如下: 把前缀后后缀元素放在一个带有 class .input-group 的 <div> 中. 接着,在相同的 &

Bootstrap&lt;基础十六&gt; 导航元素

Bootstrap 提供的用于定义导航元素的一些选项.它们使用相同的标记和基类 .nav.Bootstrap 也提供了一个用于共享标记和状态的帮助器类.改变修饰的 class,可以在不同的样式间进行切换. 表格导航或标签 创建一个标签式的导航菜单: 以一个带有 class .nav 的无序列表开始. 添加 class .nav-tabs. 下面的实例演示了这点: <!DOCTYPE html> <html> <head> <title>Bootstrap 实

Bootstrap&lt;基础十&gt; 响应式实用工具

Bootstrap 提供了一些辅助类,以便更快地实现对移动设备友好的开发.这些可以通过媒体查询结合大型.小型和中型设备,实现内容对设备的显示和隐藏. 需要谨慎使用这些工具,避免在同一个站点创建完全不同的版本.响应式实用工具目前只适用于块和表切换.   超小屏幕手机 (<768px) 小屏幕平板 (≥768px) 中等屏幕桌面 (≥992px) 大屏幕桌面 (≥1200px) .visible-xs-* 可见 隐藏 隐藏 隐藏 .visible-sm-* 隐藏 可见 隐藏 隐藏 .visible-

Bootstrap &lt;基础十九&gt;分页

Bootstrap 支持的分页特性.分页(Pagination),是一种无序列表,Bootstrap 像处理其他界面元素一样处理分页. 分页(Pagination) 下表列出了 Bootstrap 提供的处理分页的 class. Class 描述 示例代码 .pagination 添加该 class 来在页面上显示分页. <ul class="pagination"> <li><a href="#">«</a><

Bootstrap&lt;基础十四&gt; 按钮下拉菜单

使用 Bootstrap class 向按钮添加下拉菜单.如需向按钮添加下拉菜单,只需要简单地在在一个 .btn-group 中放置按钮和下拉菜单即可.也可以使用 <span class="caret"></span> 来指示按钮作为下拉菜单. 下面的实例演示了一个基本的简单的按钮下拉菜单: <!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 基本的按钮下拉菜单&

Bootstrap &lt;基础十二&gt;下拉菜单(Dropdowns)

Bootstrap 下拉菜单.下拉菜单是可切换的,是以列表格式显示链接的上下文菜单.这可以通过与 下拉菜单(Dropdown) JavaScript 插件 的互动来实现. 如需使用下列菜单,只需要在 class .dropdown 内加上下拉菜单即可.下面的实例演示了基本的下拉菜单: <!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 下拉菜单(Dropdowns)</title> <li