Skip to Content

Enhancing BP Search without using AET

Sometimes there is a requirement to enable BP search for some already existing standard BP Fields which are not present in the standard search query structure of BP. AET is not a solution in this case as the field to be searched for already exists in the standard tables and has to be handled in a more specific manner than the code generated by AET.

The standard dynamic query object of BP is – BuilHeaderAdvancedSearch and the underlying query structure is - CRMT_BUPA_IL_HEADER_SEARCH.

Let’s define a problem statement to elucidate the steps needed for such a BP Search Enhancement.

Problem Statement:

Enhance the BP Search for enabling search on “Middle Name”.

Solution:

“Middle Name” is a standard BP Field present in BUT000 table, but the standard BP Search doesn’t have this field. Following steps will help fulfill this requirement:

  1. Append the additional field to the BP Search structure - CRMT_BUPA_IL_HEADER_SEARCH



Once the field is added in the search structure, it will start reflecting in the corresponding search query object as well:

  2.    After step 1, it would be possible to expose the search field – “Middle Name” on the UI by displaying it in the UI config of the search view from the available fields of the search context node. However, the system is not yet ready to search on this field as there is no logic written in the backend that instructs the system on what to do when a search is made on this field.

To enhance the search query for searching for this field, the enhancement spot CRM_BUPA_IL_SEARCH should be enhanced for BAdI - BADI_CRM_BUPA_IL_SEARCH_EXT

The method IF_EX_CRM_BUPA_IL_SEARCH_EXT~SEARCH_CRITERIA_INITIAL should be implemented to check if any of the three added fields are searched for. If they have been searched for, then the Badi is not initial.

DATA : ls_search_criteria    TYPE crmt_bupa_il_header_search.

  MOVE-CORRESPONDING is_parameters TO ls_search_criteria.
* Check if the search is made on middlename field
* If any of the additional fields are searched, the BAdI implementation will be called.
  IF  ls_search_criteria-zzmiddlename    IS NOT INITIAL .
    cv_is_not_initial = abap_true.
  ELSE.
    cv_is_not_initial = abap_false.
  ENDIF.

In the method - IF_EX_CRM_BUPA_IL_SEARCH_EXT~SEARCH_PARTNERS, write the search query for each of the added fields.

*Search for the parameter "Middlename"
  IF ls_search_criteria-zzmiddlename IS NOT INITIAL.
    DESCRIBE TABLE ct_partner_keys LINES lv_lines.
    READ TABLE it_selection_parameters INTO ls_selection_params  WITH KEY attr_name = ‘ZZMIDDLENAME’.
    IF  lv_lines = 0.
      SELECT partner partner_guid FROM but000 INTO TABLE ct_partner_keys UP TO iv_max_hit ROWS
      WHERE MIDDLENAME = ls_selection_params-low.
    ELSE.
      SELECT partner partner_guid FROM but000 INTO TABLE ct_partner_keys FOR ALL ENTRIES IN ct_partner_keys
      WHERE partner = ct_partner_keys-partner AND MIDDLENAME = ls_selection_params-low.
    ENDIF.
  ENDIF.

……………………………………………………………………………………………

This concludes the steps for enhancing BP search for standard fields not available in the BP Search structure. These steps are applicable for not just BuilHeaderAdvancedSearch query object but other BP Query objects that use the same query structure and call stack as BuilHeaderAdvancedSearch.

Additionally, in this particular example, “Middle Name” was made searchable, but the same steps can be used to make any BP related field searchable, not necessarily belonging to BUT000. Appropriate query (using Joins if needed) can be written in the BADI method – search_partners to accomplish this.

Tags:
Former Member