Create View on CRM Home Page
SAP CRM Web UI has information on the Home Page itself so that specific information for logged in useris displayed on the Home Page. This information includes Today’s Appointments, Tasks, Workflow Tasks etc.
Objective of this Blog is to lay down the steps to configure a similar View on Home Page. One of the case Example we can take is to Create a View on Home Page to Show all the Opportunities for which Logged in user is part of Sales team.
Components : CRMCMP_GS_WC ( Component for Work Center). This component contains standard Home Page views as well.
WCC_SLS_HOME – Component for Home Page. This Window encapsulates all the views of Component CRMCMP_GS_WC.
- Create Custom View in CRMCMP_GS_WC.
Since we are planning to Read/Display the Opportunities in this view, the Model Entity for the context Node of View would be the Result of Query Object –
The View should be of ‘Table View’ Type.
- Query the Opportunities (based on Pre-determined conditions) to Display.
– Create a Custom Method GET_OPP in Impl Class of View to Query the Opportunities. The logic to obtain the required data is written in this method. In this scenario, the opportunities where logged in user is entitled as employee responsible.
Implement the Below Logic to Query Opportunities.
lr_query_service = cl_crm_bol_dquery_service=>get_instance( ‘BTQOpp’ ).
* Get BP of Logged in User
CALL FUNCTION ‘COM_BPUS_BUPADATA_FOR_USER_GET’
is_username = sy-uname
ev_businesspartner = lv_login_user
If lv_login_user is not initial.
lv_query_service->add_selection_param( iv_attr_name = ‘EMPLOYEE_RESP’ iv_sign = ‘I’ iv_option = ‘EQ’ iv_low = lv_low )
* Global variable for Collection of results gr_col
If lr_query_service IS BOUND.
gr_col = lr_query_service->get_query_result( ).
- This method implemented to Query the results can be used on initiation of view. We are redefining DO_INIT_CONTEXT & calling custom method GET_OPP in this method to fetch the collection.
lr_col = get_query_result( ).
me->typedcontext->BTQROPP->collection_wrapper->set_collection( lr_col ).
- Change View Layout of HTM page
data: lv_xml type string.
lv_xml = controller->CONFIGURATION_DESCR->GET_CONFIG_DATA( ).
<chtmlb:configCellerator xml=”<%= lv_xml %>”
design = “TRANSPARENT”
fillUpEmptyRows =” “
usage = “HOMEPAGE”
editMode = “NONE”
visibleRowCount = “10” />
- Create a Window for displaying Custom View.
Create Window using Wizard to encapsulate the custom view.
- Redefine Get P Method for the field which is required to be used as hyperlink to navigate to other pages from home page.
We are going to use Object ID field to be shown as hyperlink and generate the event on clicking.
|Logic in Get P Method|
rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
rv_value = ‘OPP_OVP’.
- Create Event in Custom view to navigate to Overview Page.
Logic in Event OPP_OVP to Navigate to Overview page.
* Get Event Index info
iv_event = htmlb_event_ex
ev_index = lv_index ).
* Feed Selected entity to outbound plug
lr_current = me->typed_context->BTQROpp->collection_wrapper->find(
CHECK lr_current is BOUND.
CALL METHOD lr_current->get_property_as_value
iv_attr_name = ‘GUID’
ev_result = lv_guid.
lr_core = cl_crm_bol_core=>get_instance( ).
CALL METHOD lr_core->get_root_entity
iv_object_name = ‘BTOrder’
iv_object_guid = lv_guid
rv_result = lr_entity.
CATCH cx_crm_genil_model_error .
create object lr_col.
lr_collection->IF_BOL_BO_COL~ADD( lr_entity ).
op_opp_ovp( lr_collection ).
- Create Outbound Plug in Custom View.
Call Window Outbound Plug and pass collection
lr_window_ctr = me->get_window_controller( ).
lr_window_ctr->call_outbound_plug( IV_OUTBOUND_PLUG = ‘OPP_OVP’
IV_DATA_COLLECTION = IV_DATA_COLLECTION ).
- Create an Outbound Plug in Custom Window as well.
Write the below logic in O/B plug OPP_OVP in window.
me->fire_outbound_plug( iv_outbound_plug = ‘OPP_OVP’
iv_data_Collection = iv_data_collection ).
- Go to Run time repository of CRMCMP_GS_WC component & Edit
– Add View to window
Add Custom View to Newly created window. Also attach the O/B plug.
– Add Component Interface
Add Component interface for custom window. Also attach O/B plug as well.
- Enhance component WCC_SLS_HOME in appropriate enhancement set
Component WCC_SLS_HOME is the actual window for home page. So it should also be configured for the changes.
– Add Component Usage
Component usage of custom view is to be added in the component WCC_SLS_HOME
– Create Outbound Plug in the component usage.
Delegate Outbound plug to Window Outboung plug UIU_APPLICATION.
– Add Custom view in Viewset of WCC_SLS_HOME.
– Change UI Configuration of WCC_SLS_HOME to accomodate the new view.
This will govern the positioning of the custom window on home page.
- Change UI configuration of CRMCMP_GS_WC to control view display.
These steps should be a complete set of activities so that a custom view can be exposed on Home Page. We can always vary the changes based on requirement as to which Business Object or View type is to be displayed.