Display and Search Business Partner Names in SAP Web UI

Issue „Display“

If a business partner is displayed in SAP Web Client UI, you will see „Firstname Lastname“ for natural persons or „Name1“ (address data maintained) or „Name 1 Name2“ (no address data maintained) for organizational Units. SAP Standard will never display „Name2“ even if your common design logic ensures that name1 is always prefix of name2.

Issue „Search“

The search is only working for „Lastname“, „Firstname Lastname“ and „Lastname, Firstname“ resp. „Name1“, „Name2 Name1“ and „Name1, Name2“. Search by „Name1 Name2“ or „Name2“ is not working for organizational units. Maybe it is working but only if Name2 contains spaces and if first word of Name2 is equal to Name1.

Challenge
If you want to change & harmonize this logic (especially to resolve the mismatch between display and search), you have to implement BADI BUPA_DESCRIPTION_GET which is used by function module BUPA_DESCRIPTION_GET, BUP_PARTNER_DESCRIPTION_GET and CRM_BUPA_DESCRIPTION_READ.

In SAP CRM standard (and therefore in some cases of SAP Solution Manager as well), the first address line determined by function module ADDRESS_INTO_PRINTFORM is used if the business partner has valid address data (please have a look at method method MOD_ATTR_DATA of class CL_CRM_PARTNER_RUN_BTIL). To change the building logic of the address lines, you have to create and register an own address layout key (900..999) in customizing view V_T005_BAS. You have to implement user exit SZAD0001. BADI BUPA_DESCRIPTION_GET or ADDR_PRINTFORM_SHORT cannot be used here. However in SAP CRM this additional implementation is needed but in SAP Solution Manager you can assume, that mostly BADI BUPA_DESCRIPTION_GET will work, if you have implemented SAP note „2157087 – Partner function „Support team“ only show Name1 in display mode“ in an extended version (Implement it. Remove restriction to a specific partner function and to display mode. Implement it for UI component AIC_CMCR_H and AIC_CMCD_H as well – not only for AIC_INCIDENT_H).

The search logic is located in function module COM_PARTNER_IDENTIFY which is called by method identify_partner of class cl_crm_uiu_bt_partner. (Please search for call of form fill_matchcode_fields). There is no BADI available, therefore you have to use modification or implicit enhancement techniques. Please ensure that SAP notes „1713745 – Search of Org. Unit by name is not working“ and „2280570 – Search of Org. Unit by name is not working II“ are implemented, because these notes change the search logic for organizational units. Please perform a modification in function module COM_PARTNER_IDENTIFY and replace „CONCATENATE LV_ENTRY ‚*‘ INTO LS_SELECTION_OPTION-LOW“ by „MOVE LV_ENTRY TO LS_SELECTION_OPTION-LOW“ in case search by name2 is not working for organizational units having no space in name2. You also have to replace „if not name1 is initial.“ by „if not name2 is initial.“ a few lines before (line 812 in my code).

*"----------------------------------------------------------------------
*"Methoden Signatur:
*"  Importing
*"     VALUE(IS_BUT000) TYPE BUT000
*"     VALUE(IV_ADDRNUMBER) TYPE AD_ADDRNUM
*"     VALUE(IV_VALDT) TYPE BAPIBUS1006_VALIDITY-VALID_DATE
*"     VALUE(IV_BAPI_ENVIROMENT) TYPE FLAG
*"  Changing
*"     VALUE(EV_DESCRIPTION) TYPE BU_DESCRIP
*"     VALUE(EV_DESCRIPTION_NAME) TYPE BU_DESCRIP
*"     VALUE(EV_DESCRIP_NAME_LONG) TYPE BU_DESCRIP_NAME_LONG
*"     VALUE(EV_DESCRIPTION_LONG) TYPE BUS000FLDS-DESCRIP_LONG
*"----------------------------------------------------------------------

METHOD if_ex_bupa_description_get~modify.

  DATA:
    lv_ext_id TYPE string.

  CASE is_but000-type.

*- Person ------------------------------------------------------------------------
    WHEN 1.

*Return Full Name
      ev_description_long = is_but000-name1_text.

*If Full Name is empty, return first and last name.
      IF ev_description_long IS INITIAL.
        ev_description_long = condense( is_but000-name_first && ` ` && is_but000-name_last ).
      ENDIF.

*- Organization ------------------------------------------------------------------------
    WHEN 2.

*Return Name 2 (Full Organization Name)
        ev_description_long = is_but000-name_org2.

*If Name 2 is empty, return Name 1 only (Short Organization Name)
        IF ev_description_long IS INITIAL.
          ev_description_long = is_but000-name_org1.
        ENDIF.

*- Group ------------------------------------------------------------------------
    WHEN 3.

*Return Full Name
      ev_description_long = is_but000-name1_text.

*If Full Name is empty, return Name 1 and Name 2.
      IF ev_description_long IS INITIAL.
        ev_description_long = condense( is_but000-name_grp1 && ` ` && is_but000-name_grp2 ).
      ENDIF.

  ENDCASE.

*Return the same value for all returning parameters.
  ev_description = ev_description_name = ev_descrip_name_long = ev_description_long.

ENDMETHOD.

METHOD CL_AIC_CMCR_AICCMCRHEADER_CN04->get_header_fct.
METHOD CL_AIC_CMCD_BTPARTNERSET_CN->get_header_fct.

  DATA: lo_bol_entity     TYPE REF TO if_bol_bo_property_access.

  CLEAR rv_partner_value.

  lo_bol_entity = cl_ai_crm_bp_helper=>get_partner_bol_entity(
    iv_process_type      = me->mo_view_controller->get_process_type( )
    iv_partner_fct_order = iv_partner_fct_order
    io_col_iterator      = io_col_iterator
    io_col_wrapper       = me->collection_wrapper ).

*{   REPLACE
*\  rv_partner_value = cl_crm_uiu_bt_partner=>get_partner2( lo_bol_entity ).
*SAP Note 2157087 extended version:
      DATA lv_value             TYPE bu_partner.
      DATA lv_value_full        TYPE bu_partner.
      DATA lv_description_name TYPE bu_descrip.
      DATA lt_return           TYPE TABLE OF bapiret2.
      lv_value = cl_crm_uiu_bt_partner=>get_partnerno( lo_bol_entity ).
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = lv_value
        IMPORTING
          output = lv_value_full.

      CALL FUNCTION 'BUPA_DESCRIPTION_GET'
        EXPORTING
          iv_partner          = lv_value_full
*           IV_PARTNER_GUID     =
*           IV_VALDT            = SY-DATLO
        IMPORTING
          ev_description_name = lv_description_name
        TABLES
          et_return           = lt_return.

      MOVE lv_description_name TO rv_partner_value.
*}   REPLACE

ENDMETHOD.