Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Intro:

Let's assume that there is a component which implements an advanced search page where we'd like to enable Saved Search possibility. There are MainWindow window, ViewSet, Search and Result views. ViewSet consists of two view areas SearchVA and ResultVA. BTQAct is used as an advanced search object from ONEORDER component set. It has BTQRAct object as a result. Own UI object (ZWC_SCON here) is used to enable navigation to this component. This component already provides basic functions: it can be started from WebUI, can run search and display results.

Steps to go:

1. Add two value nodes to component controller's context:

node NAVIGATIONDESCRIPTOR with field UI_OBJECT_TYPE type BSP_DLC_OBJECT_TYPE and

node LAUNCHERINFO with field GOREQUESTED type STRING

2. In method IF_BSP_MODEL~INIT of the node NAVIGATIONDESCRIPTOR set property UI_OBJECT_TYPE as a corespondent UI object which is related to this component.

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.

    lv_value_node->if_bol_bo_property_access~set_property_as_string( iv_attr_name = 'UI_OBJECT_TYPE'
                                                                     iv_value     = 'ZWC_SCON' ). "#EC NOTEXT

    lv_bo_coll->add( lv_value_node ).

    set_collection( lv_bo_coll ).


endmethod.

3. Add Component Usage SavedSearchRegistration. It points to component CRM_SAVEDSEARCH and its interface view RegistrationWindow.

4. Redefine method WD_USAGE_INITIALIZE of component controller class and create binding from BTQACT to ADVANCEDSEARCH and from NAVIGATIONDESCRIPTOR to NAVIGATIONDESCRIPTOR nodes of component usage SavedSearchRegistration.

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 = 'BTQACT'
              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.                                   "#EC CATCH_ALL
          RETURN.
      ENDTRY.

  ENDCASE.
ENDMETHOD.

5. Add view area SavedSearchRegistration to ViewSet's htm page.
6. Create this view area in Runtime Repository and bind component usage SavedSearchRegistration to it.

Remark: it's possible to use only one inbound plug, but for better understanding separated plugs are used.

7. Create an inbound plug SavedSearchGo in MainWindow with the 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 an inbound plug SavedSearchEdit in MainWindow with the 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->btqact->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 SavedSearchEdit 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->btqact->set_collection( lr_bol_collection ).

* execute search
  me->eh_onsearch( ).

* show selection criteria
  lv_collapsed = abap_false.
  me->typed_context->ui->set_searchcollapsed( attribute_path = ''
                                              value          = lv_collapsed ).
endmethod.

11. Create Navigational Links SavedSearchGo and SavedSearchEdit from MainWindow (without outbound plug) to an appropriate plug in Search view.

12. In SPRO -> CRM -> UI Framework -> Technical Role Definition -> Define Work Area Component Repository for this component/window create Target IDs. Define UI object and actions there (F - for button Go and A - for button Advanced in Saved Search area at the top of the WebUI page).

13. Add these Target IDs to Define Generic OP Mapping section in Navigation Bar Profile.

14. Check that UI object used here has GenIL Component Name and BOL Object Name set. It can happen that desired GenIL component has not been loaded yet and when you try to navigate to saved search the dump will occur. This settings prevent the dump and make system load appropriate component at startup of the user session.

Result:

The component got Saved Search functionality.

3 Comments

  1. Former Member

    Your article helped me a lot.

    Thank you.

  2. Guest

    Hello Andrey ,

      I am facing one issue in Saved search and i have created a Question thread for the same. Below is the link which takes to Question.

    http://scn.sap.com/thread/3399848

    Please tell me where i am going wrong.

    Thanks and Regards,

    Nikhil Kulkarni