先看一下效果。
创建Web Dynpro组件ZTEST_SAM_SELECT。
引用WDR_SELECT_OPTIONS组件
在View的属性中添加selectoptions
在layout中添加按钮和ViewContainerUIElement
嵌入SELECT OPTIONS视图
设置SELECT_SCREEN
在MAIN view中methods的WDDOINIT方法中添加如下代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
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 'MATNR' '物料编码' abap_false. mcr_sel 'MATKL' '物料组' abap_false. |
添加context和Table显示数据
查询和显示数据
在Button的ACTION中添加如下代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
*获取SELECT OPTIONS FIELD-SYMBOLS: <fs_matnr> TYPE ANY TABLE, <fs_matkl> TYPE ANY TABLE. DATA lv_matnr TYPE matnr . "屏幕上输入的 DATA lv_matkl TYPE matkl . "屏幕上输入的 DATA:lo_data TYPE REF TO data. FREE lo_data. lo_data = wd_this->m_handler->get_range_table_of_sel_field( 'MATNR' ). ASSIGN lo_data->* TO <fs_matnr>. FREE lo_data. lo_data = wd_this->m_handler->get_range_table_of_sel_field( 'MATKL' ). ASSIGN lo_data->* TO <fs_matkl>. *数据绑定 DATA lo_nd_lt_mara TYPE REF TO if_wd_context_node. DATA lt_lt_mara TYPE wd_this->elements_lt_mara. lo_nd_lt_mara = wd_context->get_child_node( name = wd_this->wdctx_lt_mara ). SELECT * INTO TABLE lt_lt_mara FROM mara WHERE matnr IN <fs_matnr> AND matkl IN <fs_matkl>. lo_nd_lt_mara->bind_table( new_items = lt_lt_mara set_initial_elements = abap_true ). |
然后就可以测试了。
附:
获取设置节点和元素
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
data:lo_nd type ref to if_wd_context_node, lo_el type ref to if_wd_context_element. data:gt_rfq type wd_this->elements_gt_rfq, ga_rfq type wd_this->element_gt_rfq. * data:lv_sptyp type zsptyp. data:ga_head type wd_this->element_zs_head. define get_node. free: lo_nd,lo_el. lo_nd = wd_context->get_child_node( &1 ). lo_el = lo_nd->get_element( ). lo_el->get_static_attributes( importing static_attributes = &2 ). end-of-definition. define set_node. free: lo_nd,lo_el. lo_nd = wd_context->get_child_node( &1 ). lo_el = lo_nd->get_element( ). lo_el->set_static_attributes( exporting static_attributes = &2 ). end-of-definition. define get_node_table. free: lo_nd,lo_el. lo_nd = wd_context->get_child_node( &1 ). lo_nd->get_static_attributes_table( importing table = &2 ). end-of-definition. define set_node_table. free: lo_nd,lo_el. lo_nd = wd_context->get_child_node( &1 ). lo_nd->bind_table( &2 ). end-of-definition. get_node_table: 'GT_RFQ' gt_rfq. |
以上。
发表评论