Skip to Content

Scenario : We have multiple transaction types  in use under quotations and reps who are using CRM wants to see one transaction type search data by default.

Multiple ways of doing it…one way!

Step 1 : UI Component and View  -> BT115QS_SLSQ

/wp-content/uploads/2015/04/image001_690565.png

Step 2 : BSP_WD_CMPWB – UI Component Workbench

/wp-content/uploads/2015/04/image003_690594.png

Step 3 : Click on Enhance Component

/wp-content/uploads/2015/04/image005_690596.png

Step 4 : Assign Enhancement Set -> Choose from drop down

/wp-content/uploads/2015/04/image007_690597.png

Step 5 :  Name Application (Ex Z of Component)

/wp-content/uploads/2015/04/image009_690598.png

Step 6 : Click  on Yes, when system confirms with pop up of (The BSP application does not exist. Do you want to create it?)

/wp-content/uploads/2015/04/image011_690599.png

Step 7 : Click on Continue, when system confirms with pop up of Input of Runtime Repository Storage Location -> Page = Repository.xml

/wp-content/uploads/2015/04/image013_690600.png

Step 8: System confirms with pop up of Workbench Request to add in TR

/wp-content/uploads/2015/04/image015_690605.png

Step 9 : We assigned to Ehn Set and  Enhanced Component.

/wp-content/uploads/2015/04/image017_690606.png

Step 10 : Transaction Code SM 34

-> Enter View Cluster : BSPWDVC_CMP_EXT

-> Display

-> Select Enhancement Set

-> Enhancement Definition – > Select Component Name -> Details

/wp-content/uploads/2015/04/image019_690607.png

Note : No entries under Controller Substitutes

Step 11 : Go back to transaction code BSP_WD_CMPWB

->Enter component BT115QS_SLSQ – Display

->Views

->Select  view – BT115QS_SLSQ/SlsQuotSQ

->Right Click-> Enhance

->Class is not Z

/wp-content/uploads/2015/04/image021_690608.png

Step 12 : System confirms with pop up of Workbench Request to add in TR

Step 13 : Assign Package or put it in Local Object if you don’t consider to move transport.

Step 14 : View color changes to Black and Class is in Z now..

Note: Repeat Step 10, you will find one entry under Controller Substitutes

/wp-content/uploads/2015/04/image027_690609.png

Step 15 : Double click on Implementation Class ZL_BT115QS__SLSQUOTSQ_IMPL

->Uncheck Filter if it is Checked

/wp-content/uploads/2015/04/image029_690610.png

Step 16 :

->Click on Edit

->Search Method  DO_PREPARE_OUTPUT

->Select and Click on Redefine

/wp-content/uploads/2015/04/image031_690611.png

Step 17 : Next screen looks like this .

/wp-content/uploads/2015/04/image033_690612.png

Step 18 : Copy Paste below code and change your Transaction Type

METHOD do_prepare_output.

* demo coding for prefilling a search attribute in the search UI

* the prefilling happens on the first time,

* the user can then also change the attribute in the UI later on

  DATA: lr_qs           TYPE REF TO cl_crm_bol_dquery_service,

        lr_search_node  TYPE REF TO cl_bsp_wd_context_node_asp,

        lr_col          TYPE REF TO if_bol_bo_col ,

        lr_iterator     TYPE REF TO if_bol_bo_col_iterator ,

        lr_param        TYPE REF TO if_bol_bo_property_access,

        ls_selection    TYPE genilt_selection_parameter,

        lv_low          TYPE string,

        lv_attr_name    TYPE name_komp ,

        lv_value_set    TYPE abap_bool .

* the attribute that shall be prefilled:

* note they have to be available in the search view configuration

* not necessarily as visible, but as available (in the ddlb)

  lv_attr_name = ‘PROCESS_TYPE’. ” for the Transaction Type filling

* the value for prefilling.

  lv_low = ‘ZSAG’ . “(Default only ZSAG on Search.)”

  IF iv_first_time EQ  abap_true.

* to initialize the search view.

    CALL METHOD super->do_prepare_output

      EXPORTING

        iv_first_time = iv_first_time.

* fetch the search node and its content.

    lr_qs = me->get_current_dquery( ).

    lr_col = lr_qs->get_selection_params( ).

* check the currently visible search attributes.

    lr_iterator = lr_col->get_iterator( ).

    lr_param    = lr_iterator->get_first( ).

    WHILE lr_param IS BOUND.

* get the parameters

      lr_param->get_properties( IMPORTING es_attributes = ls_selection ).

      IF ls_selectionattr_name = lv_attr_name .

* SET_PROPERTIES

        ls_selectionlow = lv_low .

        CALL METHOD lr_param->set_properties

          EXPORTING

            is_attributes = ls_selection.

        lv_value_set = abap_true .

        EXIT.

      ENDIF.

      lr_param = lr_iterator->get_next( ).

    ENDWHILE.

    IF lv_value_set EQ abap_false .

* it was not part of the visible attributes, then add it at the end.

      CALL METHOD lr_qs->add_selection_param

        EXPORTING

          iv_attr_name = lv_attr_name

          iv_sign      = ‘I’

          iv_option    = ‘EQ’

          iv_low       = lv_low.

    ENDIF.

* for a proper display of the added / changed attribute.

    lr_search_node = get_dquery_cnode( ).

    lr_search_node->build_parameter_tab( ).

  ELSE.

* non first time call – just delegate to superclass.

    CALL METHOD super->do_prepare_output

      EXPORTING

        iv_first_time = iv_first_time.

  ENDIF.

ENDMETHOD.

Step 19 : Syntax Check, Save and Activate

/wp-content/uploads/2015/04/image035_690613.png

Step 20 : Click on Back, now your method color is in Black.

If you click on filter,  method DO_PREPARE_OUTPUT also be shown because you added logic.

/wp-content/uploads/2015/04/image038_690614.jpg

Test Result : Quotation Type is Set to ZSAG under Search->Quotations

/wp-content/uploads/2015/04/image040_690615.jpg

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. Ratna Rajesh .P

    Good News for all the people who are trying to default the values in the Search Page.

    SAP has provided a note if you are on EHP2 or above .

    Note : 2045936

    Discription : To be able to set default values in the parameters of an advanced search page for all users in a specific role. The user should also be able to personalize his own default values.

    We have implemeted this and it works perfect 🙂

    Thanks,

    Rajesh P

    (0) 
    1. Angelika Sommer

      Hi Rajesh,

      I implemented note 2045936 (and 2057740 and2083647) in order to use default Values for Advanded Search Pages.

      I want to set default values for BP_HEAD_SEARCH/Mainsearch. How can I set them now?

      Best regards

      Angelika

      (0) 
  2. ram ram

    Good blog Pavan !!

    it is having both  information like , Enhance BSp component and default values.

    I think we can achieve the same default values using GET_VALUE1 method of context node.

    regards,rama

    (0) 

Leave a Reply