WDA基础四:Select-option的使用
Posted ^ω^SAp傻X^o^
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WDA基础四:Select-option的使用相关的知识,希望对你有一定的参考价值。
select option是方便用户和数据处理的,就是丑了点。。。
前面使用的input直接做查询条件有哥弊端,就是查询的时候需要判断字段是否有选择条件,然后要将选择条件做成range table。。。有点麻烦
1.select options 组件引入WDA程序
保存,激活。
2.将组件加入使用的视图中
双击视图,选择属性页签,在使用组件表格中点击创建,将组件对应的两个列表加进来
3.在视图的INIT中,初始化SELECT OPTIONS
3.1在视图的Attributes页签中,添加组件对象
GD_HANDLE typr ref to IF_WD_SELECT_OPTIONS.
3.2在init中初始化
DATA:LO_CP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE, LO_SELECT_OP TYPE REF TO IWCI_WDR_SELECT_OPTIONS, LT_RANGE TYPE REF TO DATA. "get the component usage LO_CP_USAGE = WD_THIS->WD_CPUSE_SELECT_OPTION( ). IF LO_CP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL. LO_CP_USAGE->CREATE_COMPONENT( ). ENDIF. "get the select option usage LO_SELECT_OP = WD_THIS->WD_CPIFC_SELECT_OPTION( ). "init the select option WD_THIS->GD_HANDLE = LO_SELECT_OP->INIT_SELECTION_SCREEN( ). WD_THIS->GD_HANDLE->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 ONE RANGE TABLE * LT_RANGE = WD_THIS->GGD_HANDLE->CREATE_RANGE_TABLE( ). CALL METHOD WD_THIS->GD_HANDLE->CREATE_RANGE_TABLE EXPORTING I_TYPENAME = \'BU_PARTNER\' RECEIVING RT_RANGE_TABLE = WD_THIS->RANGE. "LT_RANGE. CALL METHOD WD_THIS->GD_HANDLE->ADD_SELECTION_FIELD EXPORTING I_ID = \'PARTNER\' * I_WITHIN_BLOCK = MC_ID_MAIN_BLOCK I_DESCRIPTION = \'Partner\' * I_IS_AUTO_DESCRIPTION = ABAP_TRUE IT_RESULT = WD_THIS->RANGE "LT_RANGE * I_OBLIGATORY = ABAP_FALSE "必输 * I_COMPLEX_RESTRICTIONS = * I_USE_COMPLEX_RESTRICTION = ABAP_FALSE * I_NO_COMPLEX_RESTRICTIONS = ABAP_FALSE * 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_LOWER_CASE = * I_MEMORY_ID = * I_NO_EXTENSION = ABAP_FALSE * I_NO_INTERVALS = ABAP_FALSE * I_AS_CHECKBOX = ABAP_FALSE * I_AS_DROPDOWN = ABAP_FALSE * IT_VALUE_SET = * I_READ_ONLY = ABAP_FALSE * I_DONT_CARE_VALUE = * I_EXPLANATION = * I_TOOLTIP = * I_IS_NULLABLE = ABAP_TRUE * I_FORMAT_PROPERTIES = * I_SUGGEST_VALUES = * I_SUGGEST_FILTER_METHOD = .
效果:
4.在查询得时候取值(其他代码已删除,仅取得RANGE table得代码)
METHOD ONACTIONSEARCH . DATA:RT_RANGE TYPE REF TO DATA. FIELD-SYMBOLS:<FS> TYPE TABLE. RT_RANGE = WD_THIS->GD_HANDLE->GET_RANGE_TABLE_OF_SEL_FIELD( I_ID = \'PARTNER\' )."此处ID对应上面INIT中的ID ASSIGN RT_RANGE->* TO <FS>. ENDMETHOD.
5.在窗口中将SELECT-OPTION组件嵌套视图
以上是关于WDA基础四:Select-option的使用的主要内容,如果未能解决你的问题,请参考以下文章
WDA学习:Component Usage(Select Options)