webdynpro的select_option示例
需求,输入航线代码和航线编号区间,查询记录存在表中显示,并不是alv显示
1、使用组件WDR_SELECT_OPTIONS.
2.在组件控制器中加入以下组件
3、在视图属性中也添加该组件
4、创建节点
5、控件设计
6、窗口下的视图中嵌套这个视图
7、设计视图初始化方法WDDOINIT
method WDDOINIT . DATA lo_cmp_usage TYPE REF TO if_wd_component_usage. lo_cmp_usage = wd_this->wd_cpuse_select_options( ). IF lo_cmp_usage->has_active_component( ) IS INITIAL. lo_cmp_usage->create_component( ). ELSE. EXIT. ENDIF. *---选择屏幕的引用 DATA lo_interfacecontroller TYPE REF TO iwci_wdr_select_options . lo_interfacecontroller = wd_this->wd_cpifc_select_options( ). "修改SELECT_OPTIONS wd_this->m_handler = lo_interfacecontroller->init_selection_screen( ). *---设置全局信息 CALL METHOD wd_this->m_handler->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. DATA: lr_field TYPE REF TO data. DEFINE mcr_sel. free lr_field. lr_field = wd_this->m_handler->create_range_table( &1 ). wd_this->m_handler->add_selection_field( i_id = &1 "字段参考类型 i_description = &2 "描述 it_result = lr_field i_read_only = &3 ). END-OF-DEFINITION. mcr_sel ‘S_CARR_ID‘ ‘航线代码‘ abap_false. mcr_sel ‘S_CONN_ID‘ ‘航班编号‘ abap_false. endmethod.
8、设计按钮SEARCH事件方法
method ONACTIONSEARCH . *获取SELECT OPTIONS FIELD-SYMBOLS: <fs_CARRID> TYPE ANY TABLE, <fs_CONNID> TYPE ANY TABLE. DATA lv_CARRID TYPE S_CARR_ID . "屏幕上输入的 DATA lv_CONNID TYPE S_CONN_ID . "屏幕上输入的 DATA:lo_data TYPE REF TO data. FREE lo_data. lo_data = wd_this->m_handler->get_range_table_of_sel_field( ‘S_CARR_ID‘ ). ASSIGN lo_data->* TO <fs_CARRID>. FREE lo_data. lo_data = wd_this->m_handler->get_range_table_of_sel_field( ‘S_CONN_ID‘ ). ASSIGN lo_data->* TO <fs_CONNID>. *数据绑定 DATA lo_nd_sflight TYPE REF TO if_wd_context_node. DATA lo_el_sflight TYPE REF TO if_wd_context_element. DATA lt_sflight TYPE wd_this->Elements_sflight. lo_nd_sflight = wd_context->get_child_node( name = wd_this->wdctx_sflight ). SELECT * INTO TABLE lt_sflight from sflight WHERE CARRID in <fs_CARRID> AND CONNID in <fs_CONNID>. lo_nd_sflight->BIND_TABLE( NEW_ITEMS = lt_sflight ). endmethod.
9、效果展示
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。