Web dynpro的SELECT-OPTIONS做成方法

需求:

选择画面中的某个选择条件项目,需要实现复数条件检索功能.

 

解决方案:

普通的Report的话,使用系统提供的标准控件SELECT-OPTIONS即可,Web Dynpro中没有SELECT-OPTIONS控件,需要以下的步骤来完成.

 

1.     Web Dynproオブジェクト → 使用中コンポーネント → 「+」→

WDR_SELECT_OPTIONS引入,定义コンポーネントTEST_SEL_OPT

2. ビュー → 「プロパティ」タグ → コントローラ使用登録 →

  将错1.中的TEST_SEL_OPT(2)引入

3. ビュー → レイアウト → 创建ViewContainerUIElement(用来表示SELECT-OPTIONS),定义控件名:vc_test_sel_option

4.  初始化vc_test_sel_option

METHOD init_test_sel_opt .

  DATA: lt_range_table TYPE REF TO data,

        rt_range_table TYPE REF TO data,

        read_only      TYPE abap_bool,

        typename       TYPE string.

 

  DATA: lr_componentcontroller TYPE REF TO ig_componentcontroller,

        l_ref_cmp_usage        TYPE REF TO if_wd_component_usage.

 

* create the used component

  l_ref_cmp_usage = wd_this->wd_cpuse_test_sel_opt( ).

  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

    l_ref_cmp_usage->create_component( ).

  ENDIF.

  wd_this->m_wd_select_options = wd_this->wd_cpifc_test_sel_opt( ).

 

* init the select screen

  wd_this->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).

  wd_this->m_handler->set_global_options(

                              i_display_btn_cancel  = abap_false

                              i_display_btn_check   = abap_false

                              i_display_btn_reset   = abap_false

                              i_display_btn_execute = abap_false ).

 

* create a range table that consists of this new data element

  lt_range_table = wd_this->m_handler->create_range_table( i_typename = 'ZXXXX' ). 选择画面.选择项目的参照TYPE

 

* add a new field to the selection

  wd_this->m_handler->add_selection_field(

    i_id = 'S_TEST'                选择画面.选择项目名

    it_result = lt_range_table

    i_read_only = read_only

    i_value_help_type = if_wd_value_help_handler=>co_prefix_searchhelp

    i_value_help_id = 'ZXXXXX' ).

ENDMETHOD.

 

METHOD wddoinit .

wd_this->init_test_sel_opt ( ).

ENDMETHOD.

 

5. 选择画面.选择项目的选择条件值取得

METHOD get_test_from_sel_opt .

  DATA: rt_carrid TYPE REF TO data.

  FIELD-SYMBOLS: <fs_carrid> TYPE table.

 

* retrieve the data from the select option

  rt_carrid = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'S_TEST' ).

 

* assign it to a field symbol

  ASSIGN rt_carrid->* TO <fs_carrid>.

 

  p_tab_test = <fs_carrid>.

ENDMETHOD.

 

6. Window vc_test_sel_optclick ビュー埋込 → 

 埋め込まれるビュー「WND_SELECTION_SCREEN」

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