MAC结构,那与控件绑定的数据就是Context,Node 是element对象的集合,attribute即字段,element是 数据的对象形式的存在。
Node可以包含着element。
Node的property的属性介绍:
selection :可选择的element,
singleton:决定子节点加载数据,是否根据父节点lead selec,
supply function:加载数据,
(注:在componentcontroller中建立的Node,可以设置为Interface )
TextEdit和 TextView中绑定的值类型可以是STRING_TABLE,
DropdownlistByKey中默认带SE11 Domain中设定的值,也可以自动设置
lo_no_dafile = wd_context->path_get_node( path = 'DBFILE.DBFILE1' ). lo_node_info = lo_no_dafile->get_node_info( ). lo_node_info->set_attribute_value_set( EXPORTING name = 'DESC_TYPE' value_set = lt_value_set ).DropdownlistByIndex一般在alv中不同行显示不同的下拉内容。
CTable 对应类:WDR_TEST_C_TABLE;
Table对应类:WDR_TEST_TABLE;
UI对应类一般CL_WD_*开头,一般用来动态生成画面,或者动态修改UI属性;
某些時候需要控制inputfield必輸,這時候我們除了需要將state的參數設成required,還需要在程序中添加下面的一段代碼:
lr_view_api ?= mo_view. cl_wd_dynamic_tool=>check_mandatory_attr_on_view( EXPORTING view_controller = lr_view_api display_messages = abap_true IMPORTING messages = lt_result_msg ).UI的event会自带参数,一般check_box,radiobutton group 的,这时候可以增加一些event的参数。
View的 lifetime说明,控制着wddomodifyview的first_time的参数:分别代表着每次调用view的第一次执行和本wda程式中第一次调用view。
Select-Option 需要引用 WDR_SELECT_OPTIONS
但是会自带4个按钮,一般我是不需要的,所以需要隐藏,if_wd_select_options->set_global_options
ALV也是引用系统标准的WDA:SALV_WD_TABLE,对应的ALV配置的class:CL_SALV_WD_CONFIG_TABLE
其中它与绑定的数据可以通过静态和动态的方式两种。
静态方式:在Interfacecontroller_usage中绑定
动态方式:IWCI_SALV_WD_TABLE->SET_DATA( CONTEXT NODE ).
IF_SALV_WD_COLUMN_SETTINGS 列对象集合
CL_SALV_WD_COLUMN 列对象
CL_SALV_WD_COLUMN_HEADER 列header
CL_SALV_WD_UIE_* Cell UI对象
search help:WDA上的search help一共有4种:分别是automatic:會帶默認data element的search help;
dictionary search help 則是帶出se11中建立的;
Object Value Selector,OVS使用的是WDR_OVS (跟alv和select-option差不多,但是使用event触发)
优点:实现简单,可代码控制,查询条件单一,一般使用中对于查询条件要求不高,或者不需要查询条件直接列出结果。
method OVS . * declare data structures for the fields to be displayed and * for the table columns of the selection list, if necessary types: begin of lty_stru_input, * add fields for the display of your search input here field1 type sflight-carrid, field2 type sflight-connid, end of lty_stru_input. types: begin of lty_stru_list, * add fields for the selection list here column1 type sflight-fldate, column2 type sflight-carrid, column3 type sflight-connid, end of lty_stru_list. data: ls_search_input type lty_stru_input, lt_select_list type standard table of lty_stru_list, ls_text type wdr_name_value, lt_label_texts type wdr_name_value_list, lt_column_texts type wdr_name_value_list, lv_window_title type string, lv_table_header type string. field-symbols: <ls_query_params> type lty_stru_input, <ls_selection> type lty_stru_list. case ovs_callback_object->phase_indicator. when if_wd_ovs=>co_phase_0. "configuration phase, may be omitted * in this phase you have the possibility to define the texts, * if you do not want to use the defaults (DDIC-texts) ls_text-name = `FIELD1`. "must match a field name of search ls_text-value = `Airline Code`. "wd_assist->get_text( `001` ). insert ls_text into table lt_label_texts. ls_text-name = `FIELD2`. "must match a field name of search ls_text-value = `Flight Connection Number`. "wd_assist->get_text( `001` ). insert ls_text into table lt_label_texts. ls_text-name = `COLUMN1`. "must match a field in list structure ls_text-value = `Flight date`. "wd_assist->get_text( `002` ). insert ls_text into table lt_column_texts. ls_text-name = `COLUMN2`. "must match a field in list structure ls_text-value = `Airline Code`. "wd_assist->get_text( `002` ). insert ls_text into table lt_column_texts. ls_text-name = `COLUMN1`. "must match a field in list structure ls_text-value = `Flight Connection Number`. "wd_assist->get_text( `002` ). insert ls_text into table lt_column_texts. lv_window_title = `Search help of flight date`. lv_table_header = `004`. ovs_callback_object->set_configuration( label_texts = lt_label_texts column_texts = lt_column_texts window_title = lv_window_title table_header = lv_table_header ). when if_wd_ovs=>co_phase_1. "set search structure and defaults * In this phase you can set the structure and default values * of the search structure. If this phase is omitted, the search * fields will not be displayed, but the selection table is * displayed directly. * Read values of the original context (not necessary, but you * may set these as the defaults). A reference to the context * element is available in the callback object. ovs_callback_object->context_element->get_static_attributes( importing static_attributes = ls_search_input ). * pass the values to the OVS component ovs_callback_object->set_input_structure( input = ls_search_input ). when if_wd_ovs=>co_phase_2. * If phase 1 is implemented, use the field input for the * selection of the table. * If phase 1 is omitted, use values from your own context. if ovs_callback_object->query_parameters is not bound. ******** TODO exception handling endif. assign ovs_callback_object->query_parameters->* to <ls_query_params>. if not <ls_query_params> is assigned. ******** TODO exception handling endif. SELECT fldate as column1 carrid as column2 connid as column3 INTO TABLE lt_select_list FROM sflight WHERE carrid = <ls_query_params>-field1 AND connid = <ls_query_params>-field2. * call business logic for a table of possible values * lt_select_list = ??? ovs_callback_object->set_output_table( output = lt_select_list ). when if_wd_ovs=>co_phase_3. * apply result if ovs_callback_object->selection is not bound. ******** TODO exception handling endif. assign ovs_callback_object->selection->* to <ls_selection>. if <ls_selection> is assigned. ovs_callback_object->context_element->set_attribute( name = `FLDATE` value = <ls_selection>-column1 ). * or * ovs_callback_object->context_element->set_static_attributes( * static_attributes = <ls_selection> ). endif. endcase. endmethod.这个事件一共有4个阶段,
CO_PHASE_0 :Set Configuration
CO_PHASE_1:Preassign Entry Values
CO_PHASE_2:Fill Value List
CO_PHASE_3:Value Return
Freely Programmed:需要开发interface的WDA。
步骤:创建一本WDA,注:选择 Web Dynpro Component Interface,然后在implemented interfaces中添加IWD_VALUE_HELP
然后在componentcontroller中定义interface node,attributes中添加 IF_WD_VALUE_HELP_LISTENER,
同时需要在EVENT中添加一个interface的event,同时调用interface的WDA需要引用这个interface event,同时也要mapping这个interface node。