A simple test case for WDA select-options
1、Add Component WDR_SELECT_OPTIONS
2Add Component for the view
3 Create Node (0:N)
4 Create global Attribute to transport data (select-options)
5、create instance at initial method
create Select-options table when WD initial
code:
METHOD wddoinit
.
DATA lo_cmp_usage
TYPE
REF
TO if_wd_component_usage
.
DATA
:lr_t_carrid
TYPE
REF
TO
data
.
"define select-options data table
"GET INSTANCE
lo_cmp_usage
= wd_this
->wd_cpuse_select_options
(
)
.
IF lo_cmp_usage
->has_active_component
(
)
IS
INITIAL
.
lo_cmp_usage
->create_component
(
)
.
ENDIF
.
"creat handler
DATA lo_interfacecontroller
TYPE
REF
TO iwci_wdr_select_options
.
lo_interfacecontroller
= wd_this
->wd_cpifc_select_options
(
)
.
DATA lv_r_helper_class
TYPE
REF
TO if_wd_select_options
.
lv_r_helper_class
= lo_interfacecontroller
->init_selection_screen
(
)
.
*--------------set select-options field------------------------*
"create range table
lv_r_helper_class
->create_range_table
(
EXPORTING
i_typename
=
'S_CARRID'
" Type Name
RECEIVING
rt_range_table
= lr_t_carrid
" Table Range
)
.
lv_r_helper_class
->add_selection_field
(
EXPORTING
i_id
=
'S_CARRID'
" ID of Selection Field
it_result
= lr_t_carrid
" Reference to Range Table
)
.
lv_r_helper_class
->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
)
.
"set handler to global
wd_this
->m_handler
= lv_r_helper_class
.
ENDMETHOD
.
6 Create View Container and other elements
Search code:
METHOD onactionact_search
.
DATA lo_nd_node_spfli
TYPE
REF
TO if_wd_context_node
.
DATA lt_node_spfli
TYPE wd_this
->elements_node_spfli
.
DATA
:lr_t_carrid
TYPE
REF
TO
data
.
FIELD-SYMBOLS
:
TYPE
table
.
"get select-options table
wd_this
->m_handler
->get_range_table_of_sel_field
(
EXPORTING
i_id
=
'S_CARRID'
i_check_obligatory
= abap_true
RECEIVING
rt_range_table
= lr_t_carrid
)
.
ASSIGN lr_t_carrid
->*
TO
.
lo_nd_node_spfli
= wd_context
->get_child_node
( name
= wd_this
->wdctx_node_spfli
)
.
"get data
SELECT *
FROM spfli
INTO CORRESPONDING
FIELDS
OF
TABLE lt_node_spfli
WHERE carrid
IN
.
lo_nd_node_spfli
->bind_table
( new_items
= lt_node_spfli
set_initial_elements
= abap_true
)
.
ENDMETHOD
.
6 Embed view
7、Create application and test: