Você está na página 1de 10

Building WebUI Saved Searches in Your Z Component

Applies to:
WebUI in SAP CRM 2007 and CRM 7.0. For more information, visit the Customer Relationship Management homepage.

Summary
WebUI Saved Searches is equivalent to the SAPGui report variant. Frequently used search criterion on the Component search screen can be saved with a name and subsequently be called back to avoid re-entering. If you are building a Z component, this article will guide you through on how to incorporate Save Searches into your component. Author: Peng Wah Ng

Company: I&E Technology Services Created on: 18 May 2011

Author Bio
Peng Wah Ng has more than 10 years experience in SAP implementation and has played many roles; including project manager, solution architect, functional consultant in MM, SRM and CRM area and technical consultant. He has been involved in the CRM area for 6 years, since CRM 3.0. He is currently an independent senior CRM consultant.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1

Building WebUI Saved Searches in Your Z Component

Table of Contents
Introduction to Saved Searches ......................................................................................................................... 3 Inside the Saved Searches ................................................................................................................................. 4 Step 1: Link Component Search Screen to Saved Search Registration ............................................................ 4 Adding CRM_SAVEDSEARCH in Component usage .................................................................................... 4 Adding Context Nodes in the Component Controller ...................................................................................... 5 Binding the Context Nodes in the Component Controller ............................................................................... 6 Filling Context Node with Entity during Initialization ....................................................................................... 6 Adding the Saved Search Field and Button .................................................................................................... 7 Test your Saved Search Functionality ............................................................................................................ 8 Step 2: Configure the Saved Search Launcher .................................................................................................. 8 Configure the Search Action Inbound Plug ..................................................................................................... 8 Define Central Search ..................................................................................................................................... 8 Test your Launcher Functionality .................................................................................................................... 8 Related Content .................................................................................................................................................. 9 Disclaimer and Liability Notice .......................................................................................................................... 10

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 2

Building WebUI Saved Searches in Your Z Component

Introduction to Saved Searches


If you are familiar with Selection Variant in the good old SAPGui reports, then the Saved Searches is the Selection Variant in the CRM WebUI. Lets say you are the head of the Australia sales office and you frequently running a list of new quotations so that you can approve them. The search criteria will looks like below:

Click to Save the search Search Name

Since this is your favorite search criterion, instead of entering them every time, you can save the criteria by giving it a name and then click the Save button. After this is done, you will immediately see the Variant appears on the Saved Searches drop down on the top right of the UI Frame.

You can select the Saved Search from the drop down and click Go. Immediately, you will see the result screen with you selection criteria. The best part is, you can execute that search regardless where you are in WebUI and you will be navigated to the result screen.

Even though it looks like all standard delivered WebUI query components has the saved search functionality, the Saved Searches functionality does not automatically integrate to a WebUI search component. If you build a custom WebUI search component, you need to carry out some steps to integrate your component to the central search functionality. This article will cover these steps.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 3

Building WebUI Saved Searches in Your Z Component

Inside the Saved Searches


The Saved Searches functionality is actually handled by a WebUI component called CRM_SAVEDSEARCH. The component provides two views: 1. The Saved Search Registration, which contains a field for search name and the save button that can be included in the search section of the UI component. 2. The Launcher, which is the little dark blue component on the top right of the WebUI frame where you can launch your search. Integrating your custom WebUI component involves two steps, 1. Linking your component search screen to the Save Search Registration, which mainly is development work. 2. Configure the launcher to navigate to your screen and pre-filled the search parameters, which mostly are SPRO configuration. This article assumes that you are at least a medium to expert level WebUI developer who is already familiar with the development process of the WebUI components. So, it is not going to cover any of the basics, the use of tools or SPRO configuration related to that.

Step 1: Link Component Search Screen to Saved Search Registration


Adding CRM_SAVEDSEARCH in Component usage The very first step is to include the CRM_SAVEDSEARCH in the component usage so that we can use the various functionalities of the component. In the Runtime Repository Editor of the workbench, add a new component usage with the CRM_SAVESEARCHs RegistrationWindow

Pick your name

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 4

Building WebUI Saved Searches in Your Z Component

Adding Context Nodes in the Component Controller To communicate with you component, the Saved Search needs to bind to your component controller via two context nodes.

Model Node with the query BOL

Value Node Addition source code required in this method The first one is a model node that contains the same query BOL object you are using in your search view. The context node will hold the search criteria entered and passed to the Saved Search component. The second one is value node contains one field, UI_OBJECT_TYPE with data type of BSP_DLC_OBJECT_TYPE. The following source needs to be put in the IF_BSP_MODEL~INIT method of the context. Make sure you replace the <UI Object Type>. If you are using standard UI object, the value should be from table BSP_DLC_OBJ_TYPE (e.g. BT115Q_SLSQ if you are using quotation). If you created a Z UI object type, then this value should be from table BSPC_DLC_OBJ_TYPE.
METHOD if_bsp_model~init. TYPES: BEGIN OF ltype_attr_struct, ui_object_type TYPE bsp_dlc_object_type, END OF ltype_attr_struct. 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. super->if_bsp_model~init( id = id owner = owner ). 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_bo_coll->add( lv_value_node ). lv_value_node->if_bol_bo_property_access~set_property_as_string( iv_attr_name ='UI_OBJECT_TYPE' iv_value = <UI Object Type> ). set_collection( lv_bo_coll ). ENDMETHOD.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 5

Building WebUI Saved Searches in Your Z Component

Binding the Context Nodes in the Component Controller After the two component controllers context nodes are created, now we need to bind them to the Saved Search component via the component usage. In the WD_USAGE_INITIALIZE method of your component controller class, add the following code.
METHOD wd_usage_initialize. 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 = 'ADVANCEDSEARCH' iv_node_2_bind = 'ADVANCEDSEARCH'. 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. RETURN. ENDTRY. ENDCASE. ENDMETHOD.

Filling Context Node with Entity during Initialization During runtime, the component controller model node (ADVANCEDSEARCH in our example) needs to be initialized and filled with the instance of the search BOL entity so that it will hold the search criteria. This can be done in the DO_PREPARE_OUTPUT method of your search view controller class. Add the following code in the method.
DATA: lr_qs TYPE REF TO cl_crm_bol_dquery_service, lr_entity TYPE REF TO if_bol_bo_property_access, lr_comp TYPE REF TO zl_bt115qs__bspwdcomponen_impl.

IF iv_first_time = abap_true. * Get the query BOL entity from the views search BOL model node lr_qs ?= me->typed_context->btqslsquot->collection_wrapper->get_current( ). lr_comp ?= comp_controller. lr_comp->typed_context->advancedsearch->collection_wrapper->clear( ). * Saved search -> fill entity lr_comp->typed_context->advancedsearch->collection_wrapper->add( iv_entity = lr_qs ). ENDIF.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 6

Building WebUI Saved Searches in Your Z Component

Adding the Saved Search Field and Button The final step is to add the Saved Search field and button on to your search view. The RegistrationWindow of CRMD_SAVEDSEARCH component provides the two elements and we have already created a Component Usage in previous step. We just have to include into our view set. 1. In the Runtime Repository, create a new View area and include the window into your Search-Result view set. Search-Result View Set Create new View Area Include Search Registration Window from Component Usage

2. Add the view in the View Sets html page with the following thtmlb code.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 7

Building WebUI Saved Searches in Your Z Component

Test your Saved Search Functionality Up to this point, you should at be able to do the following: 1. The Save Search As field and the Save button should appear on your search screen. 2. Enter some value in your search parameters, give a Search name and click save. 3. You should see your Search name appear on the Search Launcher drop down on the top right. If everything works, the next step is to make the launcher launch the search screen and prepopulated the saved parameters.

Step 2: Configure the Saved Search Launcher


Configure the Search Action Inbound Plug You should already have the following configured for your component in the SPRO step Define Work Area Component Repository.

The Object Type and Object Action entered here is going to be used in next step. Define Central Search This is the step telling the Launcher where to go in the navigation and which context node and Search BOL to populate the search parameters. The configuration path: SPRO > Customer Relationship Management > UI Frame > Define Central Search. Add a new entry as below,

From previous step

Component Controller context node Your search BOL object As you can see, the configuration is by Navigation Bar profile. You need to add this configuration for all the Navigation Bar profile that you are going to use. Test your Launcher Functionality Login to the WebUI and make sure you Business Role is tied to the right Navigation Bar profile. If you already have saved a search in the previous step, you can select it from the launcher and click Go and it should navigate immediately to your components search screen with the parameters pre-filled.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 8

Building WebUI Saved Searches in Your Z Component

Related Content
CRM WebClient UI Wish List CRM 2007 : How to publish user saved search to all users in a business Role Save Search As option in Webui for custom Z component For more information, visit the Customer Relationship Management homepage.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 9

Building WebUI Saved Searches in Your Z Component

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

SAP COMMUNITY NETWORK 2011 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 10

Você também pode gostar