UI提供保存搜索条件的功能,标准组件是可以直接用的,如果是自建组件,就要写些代码做些配置了。
核心的一个组件就是系统标准组件CRM_SAVEDSEARCH。
下面这段涵盖了所有需要做的配置工作
<!DOCTYPE WebDynProDefinitions SYSTEM "../bc/bsp/sap/BSP_WD_COMPBASE/RuntimeRepositoryV2.dtd">
<WebDynProDefinitions version="2">
<!-- Target BSP-component id (might be used during generation) -->
<Component id="">
<!-- Models, Controllers, and Views section only relevant for a designtime repository used for code generation-->
<Models>
<!-- Reference to BOL Component Set -->
<Model id="ZFANBOLS"/>
</Models>
<Controllers>
<!-- Declaration of custom controllers -->
<Controller id="BSPWDComponent" type="COMPONENT"/>
</Controllers>
<Views>
<!-- Declaration of views -->
</Views>
<!-- Windows, ViewSets, NavigationalLinks, ComponentInterface, and ComponentUsages are parts necessary for runtime repository -->
<Windows>
<!-- Declaration of windows -->
<Window id="ZFANXX/MainWindow" default="TRUE">
<InboundPlugs/>
<OutboundPlugs/>
<EmbeddedView id="ZFANXX/viewset1" default="TRUE"/>
</Window>
</Windows>
<ViewSets>
<!-- Declaration of viewsets -->
<ViewSet id="ZFANXX/viewset1">
<ViewArea id="a">
<EmbeddedView id="ZFANXX/search" default="TRUE"/>
</ViewArea>
<ViewArea id="b">
<EmbeddedView id="SavedSearch.RegistrationWindow" default="TRUE"/>
</ViewArea>
<ViewArea id="c">
<EmbeddedView id="ZFANXX/result" default="TRUE"/>
</ViewArea>
</ViewSet>
</ViewSets>
<NavigationalLinks>
<!-- Declaration of navigation links -->
<NavigationalLink name="SAVEDSEARCHGO">
<Source outboundPlugRef="DEFAULT" viewRef="ZFANXX/MainWindow"/>
<Targets>
<Target inboundPlugRef="SAVEDSEARCHGO" viewRef="ZFANXX/search"/>
</Targets>
</NavigationalLink>
</NavigationalLinks>
<ComponentInterface id="">
<!-- Declaration of Interface views and public parts of the component controller -->
<InterfaceController/>
<InterfaceView id="ZFANXX/MainWindow" mappedToWindow="ZFANXX/MainWindow">
<InboundPlugs/>
<OutboundPlugs/>
</InterfaceView>
</ComponentInterface>
<ComponentUsages>
<!-- Declaration of the usage of other components -->
<ComponentUsage id="SavedSearch" usedComponent="CRM_SAVEDSEARCH">
<InterfaceView id="RegistrationWindow"/>
</ComponentUsage>
</ComponentUsages>
</Component>
</WebDynProDefinitions>
简单说明下
1.配置ComponentUsage
2.建了一个3行1列的viewset用来存放查询页面,结果页面,保存查询页面
3.给window做了一个IP,给搜索页面做了一个IP,把他们两个做了一个跳转
4.将重用组件的接口放到viewset里面
然后是代码
组件控制器做一个search节点,让搜索页面的这个节点和它关联。别搞反了。
组件控制器加一个NAVIGATIONDESCRIPTOR
TYPES: BEGIN OF ltype_attr_struct,
ui_object_type TYPE bsp_dlc_object_type,
END OF ltype_attr_struct.
super->if_bsp_model~init( id = id
owner = owner ).
DATA: lv_struct_ref TYPE REF TO ltype_attr_struct,
lv_value_node TYPE REF TO cl_bsp_wd_value_node,
lv_bo_coll TYPE REF TO if_bol_bo_col.
CREATE DATA lv_struct_ref.
CREATE OBJECT lv_value_node
EXPORTING
iv_data_ref = lv_struct_ref.
CREATE OBJECT lv_bo_coll TYPE cl_crm_bol_bo_col.
***搜索对象名
lv_value_node->if_bol_bo_property_access~set_property_as_string(
iv_attr_name = 'UI_OBJECT_TYPE'
iv_value = 'ZFANXX' ).
lv_bo_coll->add( lv_value_node ).
set_collection( lv_bo_coll ).
ENDMETHOD.
METHOD wd_usage_initialize.
*CALL METHOD SUPER->WD_USAGE_INITIALIZE
* EXPORTING
* IV_USAGE =
* .
* Bind context nodes to embedded components
CASE iv_usage->usage_name.
WHEN 'SavedSearch'.
TRY.
* Bind advanced search context node
CALL METHOD iv_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'SEARCH'
iv_node_2_bind = 'ADVANCEDSEARCH'.
* Bind navigation descriptor
CALL METHOD iv_usage->bind_context_node
EXPORTING
iv_controller_type = cl_bsp_wd_controller=>co_type_component
iv_target_node_name = 'NAVIGATIONDESCRIPTOR'
iv_node_2_bind = 'NAVIGATIONDESCRIPTOR'.
CATCH cx_root.
ENDTRY.
ENDCASE.
ENDMETHOD.
window建一个IP
METHOD ip_savedsearchgo.
me->view_manager->navigate( source_rep_view = me->rep_view
data_collection = iv_collection
outbound_plug = 'SavedSearchGo' ).
ENDMETHOD.
查询界面也建一个IP
METHOD ip_savedsearchgo.
DATA: lr_ex TYPE REF TO cx_root,
lr_advanced_search TYPE REF TO cl_crm_bol_dquery_service,
lr_bol_collection TYPE REF TO cl_crm_bol_entity_col,
lv_collapsed TYPE string.
TRY.
lr_advanced_search ?= iv_collection->get_first( ).
CATCH cx_root INTO lr_ex.
RETURN.
ENDTRY.
* 传保存过的查询条件进来
CREATE OBJECT lr_bol_collection.
lr_bol_collection->if_bol_bo_col~add( iv_entity = lr_advanced_search ).
typed_context->search->set_collection( lr_bol_collection ).
* 执行查询(可选)
me->eh_onsearch( ).
ENDMETHOD.
最后就是配置SPRO了。
在动态区域组件库配一个IP用于从savesearch跳转到这个自建组件
【ZFANXXGO】【SAVEDSEARCHGO】【ZFANXX】 【执行】
在相应的导航条参数文件下面的通用出站插件映射配置相应的键值
对象类型:ZFANXX
对象操作:执行
目标标识:ZFANXXGO
至此,所有事情做完了,快去登陆UI看看效果吧O(∩_∩)O~
在给个SDN上面的官方文档,还有一些参数蛮有用的。
http://help.sap.com/saphelp_nw74/helpdata/en/09/4f37bb225441e58d6581a745b8d233/frameset.htm