Skip to Content
Technical Articles

Enhancing Business Partner Search Locator

Introduction

As part of transaction BP, ‘Maintain Business Partner’, the so called ‘Locator’ provides different search possibilities in a convenient way within a standard S/4HANA system. But how is it possible to add a custom specific search functionality?

This blog post provides a step-by-step guide how to implement a new Business Partner Locator Search with the example of a search by Industry Classification. The same procedure can be used to add search functionality by any other standard or custom BP fields.

As a result, the end user will be able to look for business partners based on industry system and industry code.

This guide details the information described in a previous blog post (SAP Business Partner – Enhancing BP search criteria).

Implementation Steps

The new search functionality must ultimately be added to the locator with transaction LOCA_CUST. Before this can be done, several implementation steps must be performed as outlined below. It is a good practice to make yourself familiar with the standard search functionality. In many cases, you will be able to copy at least part of a standard search help to your new search functionality.

 

Add Additional Search Fields

Structure BUS_JOEL_SEARCH must be extended with the new search fields. This structure contains all the fields which can be used in the locator search of the business partner transaction. In our case, field industry system and industry code must be added with an append to structure BUS_JOEL_SEARCH.

  • Transaction SE11 – Data Type BUS_JOEL_SEARCH – Display
    Please check first, if your search fields are not already part of this structure.
  • Use push button ‘Append structure …’ – enter a name according to your naming convention.

  • Add a description for the append, the new search fields and assign appropriate types as well as foreign key and/or a value help definition.

  • Activate the append structure.

Create Elementary Search Help

An elementary search help must be created which uses the new search fields. This elementary search help will only be used in the collective search help assigned to the locator functionality or in BADI BUS_LOCA_HIDE_SEARCH. They cannot be used in ‘regular’ search helps assigned to field ‘Business Partner’ (value/input help).

  • Transaction SE11 – Search help Z_BUPA_ALL_INDUSTRY_SECTOR (enter a name according to your naming conventions) – Create
  • Select ‘Elementary search help’
  • Enter a description, as selection method TB038A (the table containing the industry codes), and the two search help parameters as shown below.

  • Activate the search help.

Add Elementary Search Help to Locator Search

There are two alternatives to make your new search functionality available in the ‘Find’ field in the locator.

  1. Append Elementary Search Help to the respective Locator collective Locator Search HelpsThe procedure to do so is described below.
  2. Implement BADI BUS_LOCA_HIDE_SEARCHIf you do not want to add append search helps to the standard search helps, you can create an implementation of BADI BUS_LOCA_HIDE_SEARCH. In method HIDE_SEARCH_IDS, you can insert a new entry to the method parameter table with the name of your elementary search help for the search types you want the search to be available. With such a BADI implementation you can also remove standard search ids which you do not want to present to users, or you can change the sequence in the dropdown list.

If you follow alternative one, the elementary search help must be assigned to the respective locator collective search helps. There are four different locator search helps in a standard S/4HANA system. They are tied to the ‘Find’ field in the locator.

 

Following table shows the assignment of the collective search help to the dropdown list value.

Dropdown list value Collective search help
1 Business Partner BUPA_ALL
2 Persons BUPA_PERSON
3 Organization BUPA_ORGANIZATION
4 Group BUPA_GROUP

Depending on where you want the end user to be able to use the new search functionality, you need to assign the new elementary search help to one or more of above collective search helps. The following example shows the assignment of the elementary search help Z_BUPA_ALL_INDUSTRY_SECTOR to the collective search help BUPA_ALL so that the user can find business partners by industry for all business partner types.

  • Transaction SE11 – Search Help BUPA_ALL – Display
  • Switch to tab ‘Included search helps’ and use Goto – Append Search Help … (F5)

  • In the popup screen, use push button ‘Create Append’ and enter an append name according to your naming conventions.

  • Add a short description, switch to tab ‘Included search helps’ and add the elementary search help to the append search help.

  • Activate the append search help.
    Remark: There is no need to do a parameter assignment for these kind of search helps.

Create a Function Module

A function module needs to be created which contains the logic to retrieve the business partners for the new search criteria and which provides the resulting list of BPs.

First, a new function group must be created within an appropriate package. If you are going to develop multiple new search functions, you can add the different function modules to this function group, or you can just develop one function module which holds the logic for these different search functions.

  • Transaction SE80 – Open your package – Right mouse click on package – Create – Function group

  • Add a function group name and a description – Save.

Now, the function module needs to be developed. You can either do this from scratch or you can copy one of the standard function modules. In this example, standard function module BUPA_DIALOG_SEARCH was copied to a new function module assigned to the new function group and the coding was changed accordingly.

  • E.g. Transaction SE37 – Enter function module BUPA_DIALOG_SEARCH – Use push button Copy – Enter new function module name and your function group – Use push button Copy.

  • Change coding based on your search functionality. In this example, the coding looks as shown below.
    FUNCTION z_bupa_dialog_add_search.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  IMPORTING
    *"     REFERENCE(IV_SEARCH) TYPE REF TO  CL_BUS_LOCATOR_SEARCH
    *"  EXCEPTIONS
    *"      SEARCH_VALUES_MISSING
    *"----------------------------------------------------------------------
    
    * Local data.
      DATA: ls_search_fields TYPE bus_joel_search.
    
    * Convert generic container into specific fields.
      ls_search_fields = iv_search->gv_search_fields. "#EC ENHOK
    
    * Choose the select.
      CASE iv_search->gv_search_id.
    
        WHEN 'Z_BUPA_ALL_INDUSTRY_SECTOR'.    "name of elementary search help
          CALL METHOD lcl_searcher=>select_by_industry
          EXPORTING iv_search = iv_search
                    iv_istype = ls_search_fields-zz_istype
                    iv_ind_sector = ls_search_fields-zz_ind_sector
                    EXCEPTIONS search_values_missing = 1.
    
        WHEN OTHERS.
          CLEAR sy-subrc.
      ENDCASE.
    *
      CASE sy-subrc.
        WHEN 1.
          RAISE search_values_missing.
      ENDCASE.
    
    ENDFUNCTION.​
  • Now, the local class lcl_searcher with method select_by_industry must be defined and implemented. The definition can be added to include LZ_BP_LOCATORTOP (or to a new include) and the implementation can be added to a new include. See below screen shots with sample coding based on our search by industry example.Please also add a data statement for gs_dynpro_id and a tables statement for BUS_JOEL_SEARCH which will be used later on.Method definition:
    FUNCTION-POOL Z_BP_LOCATOR.   "#EC_MG_MISS
    
    TABLES bus_joel_search.
    
    DATA gs_dynpro_id TYPE bus_screen-area.
    
    CLASS lcl_searcher DEFINITION FINAL.
    
      PUBLIC SECTION.
    
        CLASS-METHODS:
        select_by_industry
        IMPORTING iv_search  TYPE REF TO cl_bus_locator_search
                  iv_istype TYPE bus_joel_search-zz_istype
                  iv_ind_sector TYPE bus_joel_search-zz_ind_sector
                  EXCEPTIONS search_values_missing.
    
    ENDCLASS.​

    Method implementation:

    The aim of this method is to retrieve the business partner GUIDs based on the search criteria entered by the user. In our case, the selection is done based on table BUT000 to retrieve the BP GUIDs and table BUT0IS which contains the industries for the BPs.

    *&---------------------------------------------------------------------*
    *& Include          LZ_BP_LOCATORF01
    *&---------------------------------------------------------------------*
    
    CLASS lcl_searcher IMPLEMENTATION.
    *---------------------------------------------------------------------
    * METHOD select_by_industry
    *---------------------------------------------------------------------
      METHOD select_by_industry.
    *   Local data.
        DATA: lv_partner_type       TYPE bus_partner-type,
              lr_ind_sector TYPE RANGE OF but0is-ind_sector,
              lt_partner_guids  TYPE bus_partner-guid_table.
    
        CALL METHOD iv_search->get_range_for
                    EXPORTING iv_value = iv_ind_sector
                    IMPORTING et_range = lr_ind_sector.
    
    *   Determine the partner type to filter by.
        CASE iv_search->gv_search_type.
          WHEN cl_bupa_dialog_searcher=>gc_search_type_all.
            lv_partner_type = space.
          WHEN cl_bupa_dialog_searcher=>gc_search_type_person.
            lv_partner_type = '1'.
          WHEN cl_bupa_dialog_searcher=>gc_search_type_organization.
            lv_partner_type = '2'.
          WHEN cl_bupa_dialog_searcher=>gc_search_type_group.
            lv_partner_type = '3'.
        ENDCASE.
    
    *   Select the Business Partners
        IF ( lv_partner_type NE space ).
          IF ( iv_istype NE space ).
            SELECT partner_guid INTO TABLE lt_partner_guids
                   FROM but000
                   UP TO iv_search->gv_maximum_rows ROWS
                   WHERE partner IN ( SELECT partner FROM but0is WHERE ind_sector IN lr_ind_sector
                                       AND istype = iv_istype )
                   AND type = lv_partner_type.
           ELSE.
             SELECT partner_guid INTO TABLE lt_partner_guids
                 FROM but000
                 UP TO iv_search->gv_maximum_rows ROWS
                 WHERE partner IN ( SELECT partner FROM but0is WHERE ind_sector IN lr_ind_sector )
                 AND type = lv_partner_type.
           ENDIF.
        ELSE.
          IF ( iv_istype NE space ).
            SELECT partner_guid INTO TABLE lt_partner_guids
                   FROM but000
                   UP TO iv_search->gv_maximum_rows ROWS
                   WHERE partner IN ( SELECT partner FROM but0is WHERE ind_sector IN lr_ind_sector
                                       AND istype = iv_istype ).
           ELSE.
             SELECT partner_guid INTO TABLE lt_partner_guids
                 FROM but000
                 UP TO iv_search->gv_maximum_rows ROWS
                 WHERE partner IN ( SELECT partner FROM but0is WHERE ind_sector IN lr_ind_sector ).
           ENDIF.
        ENDIF.
    
    *   Pass result table
        CALL METHOD cl_bupa_dialog_searcher=>add_partner_guids_to_result
                    EXPORTING it_partner_guids         = lt_partner_guids
                              iv_filter_by_search_type = space
                              iv_search                = iv_search.
      ENDMETHOD.
    
    ENDCLASS.

     

Create a Screen with Search Fields

Now, a screen with the search fields must be created. This screen will be shown to the user in the locator as soon as the corresponding value in the find by was selected.

  • Transaction SE80 – Right click on your function group – Create – Screen
  • Enter a screen number – Enter a description – Select Subscreen as Dynpro Type

  • Add the two search fields with reference to structure BUS_JOEL_SEARCH to the screen. You could also add the corresponding descriptions of the selected field values to this screen.

  • Add PBO and PAI modules to the flow logic. Use forward navigation to create the modules in respective includes and code them as shown below.
    PROCESS BEFORE OUTPUT.
      MODULE dynpro_pbo.
    *
    PROCESS AFTER INPUT.
      MODULE dynpro_pai.​
    *----------------------------------------------------------------------*
    ***INCLUDE LZ_BP_LOCATORO01.
    *----------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Module DYNPRO_PBO OUTPUT
    *&---------------------------------------------------------------------*
    *&
    *&---------------------------------------------------------------------*
    MODULE dynpro_pbo OUTPUT.
    * Global data.
      gs_dynpro_id-program_name = sy-repid.
      gs_dynpro_id-dynpro_number = sy-dynnr.
    
      CALL METHOD cl_bus_abstract_screen=>dynpro_pbo
                  EXPORTING iv_program_name = gs_dynpro_id-program_name
                            iv_dynpro_number = gs_dynpro_id-dynpro_number.
    
    ENDMODULE.
    *----------------------------------------------------------------------*
    ***INCLUDE LZ_BP_LOCATORI01.
    *----------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *&      Module  DYNPRO_PAI  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    MODULE dynpro_pai INPUT.
      gs_dynpro_id-program_name = sy-repid.
      gs_dynpro_id-dynpro_number = sy-dynnr.
    
      CALL METHOD cl_bus_abstract_screen=>dynpro_pai
                  EXPORTING iv_program_name = gs_dynpro_id-program_name
                            iv_dynpro_number = gs_dynpro_id-dynpro_number.
    ENDMODULE.

Add Subroutines for Search Field

As a last development task, two sub routines must be added to pass the search fields between the locator framework and your function group.

  • Transaction SE80 – open your include for form routines and add below two form routines. These two form routines will be called from the locator framework by using the statement perform [form routine] in program [master program of the function group]. Therefore, these two routines must be added here as well.
    *---------------------------------------------------------------------*
    *       FORM bus_locator_get_search_fields                            *
    *---------------------------------------------------------------------*
    
    FORM bus_locator_get_search_fields                          "#EC CALLED
         USING    iv_search_application TYPE bus_locator-search_application
         CHANGING ev_search_fields      TYPE bus_locator-search_fields.
    
     CASE iv_search_application.
        WHEN cl_bupa_dialog_searcher=>gc_search_application_bupa.
          ev_search_fields = bus_joel_search."#EC ENHOK
      ENDCASE.
    
    ENDFORM.
    
    *---------------------------------------------------------------------*
    *       FORM bus_locator_set_search_fields                            *
    *---------------------------------------------------------------------*
    
    FORM bus_locator_set_search_fields                          "#EC CALLED
         USING    iv_search_application TYPE bus_locator-search_application
                  iv_search_fields      TYPE bus_locator-search_fields.
    
      CASE iv_search_application.
        WHEN cl_bupa_dialog_searcher=>gc_search_application_bupa.
          bus_joel_search = iv_search_fields. "#EC ENHOK
      ENDCASE.
    
    ENDFORM.​

Add Entry in LOCA_CUST

As a final step, a new entry in the locator customizing table must be added.

  • Transaction LOCA_CUST – Select ‘Search IDs’ – Use push button ‘New Entry’ – Add your elementary search, a text which will be shown in the ‘Find By’ dropdown list, your function module, the master program of your function group, and your screen number.


    Remark: It would have been possible to add a second selection screen which would be used in the full screen version of the BP Locator Search.

Using the New Search Function

After these implementation steps, it is now possible to look for Business Partners based on Industry System and Industry Code. The user can pick the new search id from the dropdown list of field ‘By’ (in our case only if search type ‘Business Partner’ was used in field ‘Find’).

Then, the user can select the industry system and the industry code and will receive a list of business partners being classified with these codes.

Conclusion

This guide is targeted to those who still use SAPGUI transaction BP or the SAP Fiori app ‘Maintain Business Partner’ (SAPGUI for HTML) and shows how to add a new search function to the Business Partner Locator. By doing so, it also shows how you could influence standard search ids. Please be aware that this enhancement does not influence the filter functionality of the ‘Manage’ SAP Fiori apps for Business Partner, Customer, and Supplier.

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