WD4A Select Options

Web Dynpro for ABAP 的查询条件可以使用Select Options。在使用Select Options时需要先进行初始化,在界面生产Select Options UI。

 

  • 初始化Select Options
method init_select_options .
************************************************************************
* 初始化 Web Dynpro select options
* 建议全部使用 selection_field,parameter_field 不能用标准功能 reset
************************************************************************
  data lo_cmp_usage type ref to if_wd_component_usage.
  data lo_interfacecontroller type ref to iwci_wdr_select_options .

  data: lr_range_table type ref to data.

  data: lt_value_set type wdy_key_value_table.  " DropDownByKey 下拉值

  lo_cmp_usage =   wd_this->wd_cpuse_select_options( ).
  if lo_cmp_usage->has_active_component( ) is initial.
    lo_cmp_usage->create_component( ).
  endif.

  lo_interfacecontroller =   wd_this->wd_cpifc_select_options( ).

  call method lo_interfacecontroller->init_selection_screen
    receiving
      r_helper_class = wd_this->select_options.

* select options 全局设置,不显示 select options 标准按钮
  call method wd_this->select_options->set_global_options
    exporting
      i_display_btn_cancel  = abap_false
      i_display_btn_check   = abap_false
      i_display_btn_reset   = abap_false
      i_display_btn_execute = abap_false.

* 增加 block as tray
  call method wd_this->select_options->add_block
    exporting
      i_id         = 'BL'
      i_block_type = if_wd_select_options=>mc_block_type_tray
      i_title      = '查询条件'.


* 增加“单据类型” as DropDownByKey
  call method wd_this->select_options->create_range_table
    exporting
      i_typename     = 'ZCDM_FORM_APP_TP'
*      i_length       =
*      i_decimals     =
    receiving
      rt_range_table = lr_range_table
      .

* 读取 domain 的值
  select domvalue_l ddtext
    into table lt_value_set
    from dd07t
    where domname = 'ZCDM_FORM_APP_TP'
      and as4local = 'A'
      and ddlanguage = '1'.

  call method wd_this->select_options->add_selection_field
    exporting
      i_id           = 'APP_TP'
      i_within_block = 'BL'
      i_description  = '单据申请类型'
      it_result      = lr_range_table
      i_no_extension = abap_true
      i_no_intervals = abap_true
      i_as_dropdown  = abap_true
      it_value_set   = lt_value_set.

  clear: lr_range_table , lt_value_set.

* 增加 “申请号” as selection field
  call method wd_this->select_options->create_range_table
    exporting
      i_typename     = 'ZCDM_APP_TOPIC_CD'
*      i_length       =
*      i_decimals     =
    receiving
      rt_range_table = lr_range_table
      .

  call method wd_this->select_options->add_selection_field
    exporting
      i_id                         = 'APP_CD'
      i_within_block               = 'BL'
      i_description                = '申请号'
      it_result                    = lr_range_table
*      i_value_help_type            =
*IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_NONE
*      i_value_help_id              =
*      i_value_help_mode            =
*      i_value_help_structure       =
*      i_value_help_structure_field =
*      i_help_request_handler       =
      i_no_extension               = abap_true
      i_no_intervals               = abap_true
      .
  clear lr_range_table.

* 增加 “选题类型” as DropDownByKey
  call method wd_this->select_options->create_range_table
    exporting
      i_typename     = 'ZCDM_TYPE_NUMBER'
*      i_length       =
*      i_decimals     =
    receiving
      rt_range_table = lr_range_table
      .

  select z_type_number z_type_desc
    into table lt_value_set
    from zcdm_t_type
    where z_type_id = 'T11'.

  call method wd_this->select_options->add_selection_field
    exporting
      i_id           = 'TOP_TP'
      i_within_block = 'BL'
      i_description  = '选题类型'
      it_result      = lr_range_table
      i_no_extension = abap_true
      i_no_intervals = abap_true
      i_as_dropdown  = abap_true
      it_value_set   = lt_value_set.

  clear: lr_range_table , lt_value_set.

* 增加“选题级别” as DropDownByKey
  call method wd_this->select_options->create_range_table
    exporting
      i_typename     = 'ZCDM_TOPIC_LEVEL'
*      i_length       =
*      i_decimals     =
    receiving
      rt_range_table = lr_range_table
      .

  select domvalue_l ddtext
    into table lt_value_set
    from dd07t
    where domname = 'ZCDM_TOPIC_LEVEL'
      and as4local = 'A'
      and ddlanguage = '1'.

  call method wd_this->select_options->add_selection_field
    exporting
      i_id           = 'TOP_LE'
      i_within_block = 'BL'
      i_description  = '选题级别'
      it_result      = lr_range_table
      i_no_extension = abap_true
      i_no_intervals = abap_true
      i_as_dropdown  = abap_true
      it_value_set   = lt_value_set.

  clear: lr_range_table , lt_value_set.

* 增加 “选题名称” as selection field
  call method wd_this->select_options->create_range_table
    exporting
      i_typename     = 'ZCDM_TOPIC_NAME'
*      i_length       =
*      i_decimals     =
    receiving
      rt_range_table = lr_range_table
      .

  call method wd_this->select_options->add_selection_field
    exporting
      i_id           = 'TOP_NM'
      i_within_block = 'BL'
      i_description  = '选题名称'
      it_result      = lr_range_table
      i_no_extension = abap_true
      i_no_intervals = abap_true.
  clear lr_range_table.

* 增加“审批状态” as DropDownByKey
  call method wd_this->select_options->create_range_table
    exporting
      i_typename     = 'ZCDM_APP_STATUS'
*      i_length       =
*      i_decimals     =
    receiving
      rt_range_table = lr_range_table
      .

  select domvalue_l ddtext
    into table lt_value_set
    from dd07t
    where domname = 'ZCDM_APP_STATUS'
      and as4local = 'A'
      and ddlanguage = '1'.

  call method wd_this->select_options->add_selection_field
    exporting
      i_id           = 'APP_STA'
      i_within_block = 'BL'
      i_description  = '审批状态'
      it_result      = lr_range_table
      i_no_extension = abap_true
      i_no_intervals = abap_true
      i_as_dropdown  = abap_true
      it_value_set   = lt_value_set.

  clear: lr_range_table , lt_value_set.

* 增加 “申报日期” as selection field
  call method wd_this->select_options->create_range_table
    exporting
      i_typename     = 'ZCDM_APDAT'
*      i_length       =
*      i_decimals     =
    receiving
      rt_range_table = lr_range_table
      .

  call method wd_this->select_options->add_selection_field
    exporting
      i_id           = 'APDAT'
      i_within_block = 'BL'
      i_description  = '申报日期'
      it_result      = lr_range_table.
  clear lr_range_table.
endmethod.

  

  • 清空(重置)Select Options
method onactionclear .
************************************************************************
* 重置 select options 为初始状态
* clear 是事件名称 onaction是系统自动在事件名前加的作为方法名
************************************************************************
* 重置 select option
  wd_this->select_options->reset_all_selection_fields( ).
endmethod.  

你可能感兴趣的:(Web,UI)