Hello,
This document will help you to create a Saved Search in your custom BSP Component.
Scenario:
I have a View Set (CompanySearchVS) with three view areas. First ViewArea (search) contains SearchView, second ViewArea (savedsearch) is empty and third ViewArea (result) contains Table View (ResultView) to display result. Second ViewArea will be used to display Saved Search textbox and save button.
![0.jpg]()
Steps to Implement Saved Search:
1. Create Component Usage
ID: SavedSearchRegistration
Used Component: CRM_SAVEDSEARCH
Interface View: RegistrationWindow
![1.png]()
Note: Step 1 will make the following new view available to use into your component SavedSearchRegistration.RegistrationWindow.
2. Add SavedSearchRegistration.RegistrationWindow in view sets view area savedsearch
![2.png]()
3. Create three context nodes in component controller as shown below
a. Name: SEARCH
Node Type: Model Node
BOL Entity: Dynamic Search Component Name (in my scenario COMPANY_DSEARCH)
b. Name: UI
Node Type: Value Node
Attributes: Add one attribute
SEARCHCOLLAPSED TYPE ABAP_BOOL
c. Name: NAVIGATIONDESCRIPTOR
Node Type: Value Node
Attribute: Add single attribute
UI_OBJECT_TYPE TYPE BSP_DLC_OBJECT_TYPE
In method IF_BSP_MODEL~INIT()of NAVIGATIONDESCRIPTOR node set property UI_OBJECT_TYPE as a correspondent UI object. As shown below
method IF_BSP_MODEL~INIT.
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.
* ZSM_INSUR_OBJ_TYPE replace with your object type
lv_value_node->if_bol_bo_property_access~set_property_as_string(
iv_attr_name = 'UI_OBJECT_TYPE' iv_value = 'ZSM_INSUR_OBJ_TYPE' ).
lv_bo_coll->add( lv_value_node ).
set_collection( lv_bo_coll ).
endmethod.
Note: Object Type Creation will be explained in Step 13.
Context Nodes will look like this.
![3.png]()
4. Redefine WD_USAGE_INITIALIZE method.
Bind SEARCH and NAVIGATIONDESCRIPTOR nodes of Component Controller with ADVANCEDSEARCH and NAVIGATIONDESCRIPTOR nodes of SavedSearchRegistration view respectively.
To do this write following code in WD_USAGE_INITIALIZE
METHOD wd_usage_initialize.
* Bind context nodes to embedded components
CASE iv_usage->usage_name.
WHEN 'SavedSearchRegistration'.
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.
5. Create Context Node in your search view.
The structure should be similar to UI Node as shown in the previous step.
Name: UI
Node Type: Value Node
Attributes: Add one attribute
SEARCHCOLLAPSED TYPE ABAP_BOOL
6. Bind SEARCH and UI Nodes of SearchView to the SEARCH and UI Nodes of Component Controller.
![6.png]()
7. Create inbound plug savedsearchgo in MainWindow. Write following code
METHOD ip_savedsearchgo.
me->view_manager->navigate( source_rep_view = me->rep_view
data_collection = iv_collection
outbound_plug = 'SavedSearchGo' ).
ENDMETHOD.
8. Create inbound plug savedsearchedit in MainWindow. Write following code
METHOD ip_savedsearchedit.
me->view_manager->navigate( source_rep_view = me->rep_view
data_collection = iv_collection
outbound_plug = 'SavedSearchEdit' ).
ENDMETHOD.
9. Create an inbound plug SavedSearchGo in Search view with the following code.
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.
* check if saved search has been received
TRY.
lr_advanced_search ?= iv_collection->get_first( ).
CATCH cx_root INTO lr_ex.
RETURN.
ENDTRY.
* register search passed
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 ).
* execute search
me->eh_onsearch( ).
* collapse selection criteria
lv_collapsed = abap_true.
me->typed_context->ui->set_searchcollapsed( attribute_path = ''
value = lv_collapsed ).
ENDMETHOD.
10. Create an inbound plug SavedSearchGo in Search view with the following code.
METHOD ip_savedsearchedit.
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.
* check if saved search has been received
TRY.
lr_advanced_search ?= iv_collection->get_first( ).
CATCH cx_root INTO lr_ex.
RETURN.
ENDTRY.
* register search passed
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 ).
* execute search
me->eh_onsearch( ).
* collapse selection criteria
lv_collapsed = abap_true.
me->typed_context->ui->set_searchcollapsed( attribute_path = ''
value = lv_collapsed ).
ENDMETHOD.
11. Create Navigation links SavedSearchGo and SavedSearchEdit between MainWindow to SearchView.
![11.png]()
12. Expose MainWindow as shown below
![12.png]()
13. Create Object Type:
Go to transaction SPRO: CRM -> UI Framework -> UI Framework Definition -> Define Object Type
![13.png]()
14. Create New Entry for the object type
![14.png]()
Note:- Now add your component to Navigation Bar. Refer following link
Add your custom BSP component as a link in a Work Center
15. Define Work Area for your component repository.
![15.png]()
16. Define your component with exposed window.
![16.png]()
17. Select created an entry and go to inbound plug.
![17.png]()
18. Go to Navigation Bar Profile
In Define Profile select SLS-PRO profile and add two entries in Define Generic OP Mapping as shown below
![18.png]()
Test your component in CRM_UI.
Hope this document is helpful.....