cancel
Showing results for 
Search instead for 
Did you mean: 

How to enhance the Agent Inbox Search functionality

Former Member
0 Kudos

Hi Experts,

Currently I am working with CRM 2007 (6.0) version. I have a requirement to enhance the Agent inbox search functionality. Below are the points regarding the requirement.

1. Reason field needs to be added to the Agent inbox search criterion

2.Need to provide the search functionality for this field.

For the above requirement I came to know that we have a badi CRM_IC_INBOX_BADI which i can use and i need to implement the method BEFORE_SEARCH. Could anybody eloborate the steps how i can add the Reason field to the search criterion and how can i provide the search functionality.

Contributions will be highly appricated.

Regards,

Lakshmana.P

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I did the following in CRM 2007 long time ago and it worked:

1. Created a context node REASON with the attribute CODE_DESCR

method GET_V_CODE_DESCR.

  if REASON_VALUEHELP is not bound.

*   Create using local type
    create object REASON_VALUEHELP type lcl_valuehelp_for_reason
                  exporting iv_source_type = if_bsp_wd_valuehelp_pldescr=>source_type_table.

  endif.

*   Load content if in runtime mode
    case iv_mode.
      when runtime_mode.
         REASON_VALUEHELP->load_selection_table( PROCESS_TYPE ).
    endcase.

* Return cached value help
  rv_valuehelp_descriptor = REASON_VALUEHELP .

endmethod.

PROCESS_TYPE is an attribute of ZL_ICCMP_IN_INBOXSEARCH_CN00 the context node class for REASON

*"* use this source file for any type declarations (class
*"* definitions, interfaces or data types) you need for method
*"* implementation or private method's signature

class lcl_valuehelp_for_reason definition friends ZL_ICCMP_IN_INBOXSEARCH_CN00.

  public section.

    interfaces: if_bsp_wd_valuehelp_pldescr.

      methods: constructor
                          importing iv_source_type type char1.

   private section.

      data: gt_selection_table type bsp_wd_dropdown_table.

      methods: load_selection_table
                                  importing iv_process_type type string.

endclass.

*"* local class implementation for public class
*"* use this source file for the implementation part of
*"* local helper classes

class lcl_valuehelp_for_reason implementation.

  method constructor.

        me->if_bsp_wd_valuehelp_pldescr~source_type = iv_source_type.

  endmethod.                    "CONSTRUCTOR

  method if_bsp_wd_valuehelp_pldescr~get_selection_table.

      rt_result = gt_selection_table.

  endmethod.                                                                                "

  method if_bsp_wd_valuehelp_pldescr~get_binding_string.
*   Value help does not come from context node here.
    raise exception type cx_bsp_wd_incorrect_implement.
  endmethod.                                                                                "

  method load_selection_table.

      data: ls_selection_table      type line of bsp_wd_dropdown_table,
            lt_selection_table      type bsp_wd_dropdown_table.

      data: lv_subject_profile type CRMT_SUBJECT_PROFILE.

      data: lv_katalogart(2)  type c,
            lt_reasons        type crmtt_codes,
            lv_reason         type crmst_code.

      clear:  gt_selection_table,
              lt_selection_table,
              lv_subject_profile,
              lv_katalogart,
              lv_reason,
              lt_reasons .


* get subject profile

  if iv_process_type is not initial.

    SELECT single subject_profile
                  from crmc_activity_h
                  into lv_subject_profile
                  where process_type = iv_process_type .

  endif.

* get reasons

 if lv_subject_profile is not initial.

     SELECT single katalogart
                   into lv_katalogart
                   from crmc_subjprofil2
                   where subject_profile = lv_subject_profile.

    If sy-subrc EQ 0. "should always find something but just in case
*     Get corresponding Reason Codes
        CALL FUNCTION 'CRM_GET_CODES_FROM_CATALOG'
          EXPORTING
            iv_subj_profile = lv_subject_profile
            iv_catalog      = lv_katalogart
          IMPORTING
            et_codes        = lt_reasons.

    endif.

 endif.


     if lt_reasons is not initial.

*          append ls_selection_table to lt_selection_table.

          loop at lt_reasons into lv_reason.

            ls_selection_table-key       = lv_reason-CONC_KEY.
            ls_selection_table-value     = lv_reason-CODE_DESCR.

            append ls_selection_table to lt_selection_table.

          endloop.

          gt_selection_table = lt_selection_table.

     endif.

  endmethod.                    "SET_SELECTION_TABLE

endclass

.

Class: ZL_ICCMP_IN_INBOXSEARCH_IMPL

method EH_ONMAINCATEGORY.
* Added by wizard: Handler for event 'maincategory'

    data: lv_process_type type string.

    lv_process_type = TYPED_CONTEXT->SEARCH->get_maincategory( attribute_path = '' ).

    ZTYPED_CONTEXT->REASON->SET_PROCESS_TYPE( lv_process_type ).

endmethod.

2.class ZL_ICCMP_IN_INBOXSEARCH_IMPL

METHOD eh_onsearch.

* REDEFINED the method to filter out the result by reason

...................................................

   lr_query->set_query_parameters( EXPORTING it_parameters = l_parameters_tab
                                            iv_convert    = abap_false ).

*   Fire the query
    IF lr_query->check_query_params_set( ) EQ abap_true.

        lr_result ?= lr_query->get_query_result( ).

* inform the user that the standard search stopped after max hits

          counter = lr_result->SIZE( ).
          l_max_hits = cl_crm_aui_service=>gv_max_hits.

         if counter = l_max_hits.

           if lr_msg_service is not bound.
             lr_msg_service = view_manager->get_message_service( ).
           endif.
.............................................
          endif.

    ENDIF.

* Filter search by Reason

    CREATE OBJECT lr_auiitems TYPE cl_crm_bol_entity_col.

    IF REASON IS INITIAL.

      lr_auiitems = lr_result.

    ELSE.
      lr_object ?= lr_result->get_first( ).
      WHILE lr_object IS BOUND.
        CLEAR lv_reason.
        TRY.
            lv_objtype = lr_object->get_name( ).
          CATCH: cx_sy_ref_is_initial cx_crm_cic_parameter_error.
        ENDTRY.

        IF lv_objtype = cl_crm_aui_oneorder=>c_btorder.

          TRY.
              lr_current ?= lr_object->get_bol_entity( ).
              col_adminh = lr_current->get_related_entities( iv_relation_name = 'BTOrderHeader' ).
              lr_current ?= col_adminh->get_current( ).
              col_bosset = lr_current->get_related_entities( iv_relation_name = 'BTHeaderBOSSet' ).
              lr_current ?= col_bosset->get_current( ).
              col_subject_f = lr_current->get_related_entities( iv_relation_name = 'BTSubjectSet_F' ).
              lr_current ?= col_subject_f->get_current( ).
              lr_current = lr_current->get_related_entity( iv_relation_name = 'BTSubject_A1' ).
              lv_reason = lr_current->get_property_as_string( 'CONC_KEY' ).
            CATCH cx_root.
              lv_reason = ''.
          ENDTRY.

          IF lv_reason = REASON.
            lr_auiitems->add( iv_entity = lr_object ).
          ENDIF.

        ENDIF.

        lr_object ?= lr_result->get_next( ).
      ENDWHILE.

    ENDIF. "  IF REASON IS INITIAL.

    TRY.
*       set result to custom controller
        typed_context->items->set_collection( collection = lr_auiitems ).
      CATCH: CX_BOL_EXCEPTION, CX_ROOT.
      ENDTRY.

**   set result to custom controller
*    typed_context->auiitems->set_collection( collection = lr_auiitems ).
  ENDIF.



* Store search criteria
*  DATA: lr_inbox_controller TYPE REF TO cl_iccmp_in_bspwdcomponen_impl.
*  lr_inbox_controller ?= me->get_custom_controller( 'ICCMP_INBOX/BSPWDComponent' )."#EC NOTEXT
*  lr_inbox_controller->store_search( ).

*   Refresh the Tree
    RAISE EVENT new_auisearch.
    RAISE EVENT refresh_tree.

ENDMETHOD.

I did not paste the whole code in either 1. or 2. but only what I considered relatively relevant.

Mihai

.................................................................................

No idea why the formatting does not work.

Answers (1)

Answers (1)

former_member1055365
Participant
0 Kudos

Hi Lakshmana,

I had the same problem on the CRM 4.0. I inherted the query BTQueryAUI, created a simple BOL query (spro->...->Define Simple Objects) and made some entries in the dynamic reporting framework (tables CRMC_REPDY & CRMC_REPDY_DB).

I checked your requirement on SAP CRM 7.0, here the result of my analysis:

Search of Inbox

the view ICCMP_INBOX/InboxSearch runs the search by doing follwing steps:

1. CL_CRM_AUI_QUERY_SERVICE->GET_1O_QUERY_RESULT

check entries, map entries on UI to search structure "CRMST_AUINBOX_SEARCH"

2. CL_CRM_QUERYAUI_RUN_BTIL->READ_BUSINESS_TRANSACTIONS

create ranges from search structure for where-clause

BAdI CRM_IC_INBOX_BADI

so I took a quick look at the BAdIs IF "IF_EX_CRM_IC_INBOX_BADI"

there the method BEFORE_SEARCH supports parameter I_INBOX_MAP_ITEM_TYPE

it seems to me, that if you start searching in inbox (CL_CRM_AUI_QUERY_SERVICE->GET_1O_QUERY_RESULT), your parameters from the BAdI are mapped against fields of structure "CRMST_AUINBOX_SEARCH" (CL_CRM_AUI_QUERY_SERVICE->MAP_PARAM_1O)

=> IMHO the BAdI is not use full for you

So what to do?

my recommandation is, to check the spro and extend query "BTQueryAUI" in customizing

=> check whether you have to extend classes CL_CRM_AUI_QUERY_SERVICE and CL_CRM_QUERYAUI_RUN_BTIL by inheritance and redefining of same methods

=> got to IMG and extend model

SPRO

-> Customer Relationship Management

-> CRM Cross-Application Components

-> Generic Interaction Layer/Object Layer

-> Component-Specific Settings

-> Business Transactions

1. Extend Model for Business Transactions with New Nodes

2. Extend Model for Business Transactions with New Relations

3. Define Custom Handler Classes for Business Transaction Model Nodes

hope, this will help you!

best wishes,

Hakan

Former Member
0 Kudos

Hi,

I also need to enhance agent inbox with one new field created_by to filter the results for one order search. Could you please guide me on how to enhance the class for BTQUERYAUI in SPRO Configuration?

Regards,

Kamesh Bathla

Former Member
0 Kudos

Hi Kamesh,

I did not do any thing with the query 'BTQueryAUI' and class 'CL_CRM_AUI_QUERY_SERVICE and CL_CRM_QUERYAUI_RUN_BTIL '. I have followed a generic process which is mentioned below

1. Enahanced the component 'ICCMP_INBOX'

2. Enhanced the view 'ICCMP_INBOX/InboxSearch '

3. Enahanced the context node 'SEARCH '

4. Added the required Z field to the context node

5. Redefined the method 'EH_ONSEARCH'

DATA: lr_query TYPE REF TO cl_crm_aui_query_service,

lr_result TYPE REF TO if_bol_bo_col,

lr_auiitems TYPE REF TO if_bol_bo_col,

lr_auiitems1 TYPE REF TO if_bol_bo_col,

lr_result ?= lr_query->get_query_result( ).

once you get the result list in to lr_result. Try to implement some custom code which is given as example below

CREATE OBJECT lr_auiitems1 TYPE cl_crm_bol_entity_col.

READ TABLE l_parameters_tab INTO ls_parameters WITH KEY name = 'ZZCAT'.

IF sy-subrc IS INITIAL.

IF ls_parameters-value IS INITIAL.

lr_auiitems1 = lr_auiitems.

ELSE.

lr_object ?= lr_auiitems->get_first( ).

WHILE lr_object IS BOUND.

CLEAR l_category.

TRY.

l_objtype = lr_object->get_name( ).

CATCH: cx_sy_ref_is_initial cx_crm_cic_parameter_error.

ENDTRY.

IF l_objtype = cl_crm_aui_oneorder=>c_btorder.

TRY.

lr_current ?= lr_object->get_bol_entity( ).

lr_col_adminh = lr_current->get_related_entities( iv_relation_name = 'BTOrderHeader' ).

lr_current ?= lr_col_adminh->get_current( ).

lr_current = lr_current->get_related_entity( iv_relation_name = 'BTHeaderActivityExt' ).

l_category = lr_current->get_property_as_string( 'CATEGORY' ).

CATCH cx_root.

l_category = ''.

ENDTRY.

IF l_category EQ ls_parameters-value.

lr_auiitems1->add( iv_entity = lr_object ).

ENDIF.

ENDIF.

lr_object ?= lr_auiitems->get_next( ).

ENDWHILE.

ENDIF. " IF Category IS INITIAL.

ELSE.

lr_auiitems1 = lr_auiitems.

ENDIF.

TRY.

  • set result to custom controller

typed_context->items->set_collection( collection = lr_auiitems1 ).

CATCH: cx_bol_exception, cx_root.

ENDTRY.

ENDIF.

Try to check the code and may be it can be helpful to get to some idea about ur requirement. Thanks

Regards,

Lakshmana.P

Former Member
0 Kudos

Hi Lakshmana,

If you do this after the results

     lr_result ?= lr_query->get_query_result( ).

you actually filtering already found results right, which could be 50 or 100, but if the record is not in this 50-100 records, the z field search fails right ??

Can you clarify this ?

Thanks

Siva