Relevance / Motivation
Once again – main motiviation is usability or user efficiency.
When using the type ahead search for Business Partners (BP) end users get too many similar proposed values and the relevant BP cannot be identified or even not found quick enough. One special Forwarder’s example: you have got many customer BPs for the same customer-company in your system – one BP per sales organization. Hence, when start typing the customer name you get the same customer proposed many times and you also need to type the country and/or city, but you (or users) don’t like to do that.
A similar Shipper’s example could be valid for the carrier side too. You might have many carrier BPs for the same carrier-company in your system – one carrier-BP per purchase organization.
Another rather simple reason could be that you have simply hundred thousands of BPs in your system and hence when start typing a name too many BPs come up with similar names.
This blog post explains how you could enhance SAP TM in order to use a special type ahead search help, which e.g. uses the sales org of the FWO to narrow down the number of relevant BPs. As a result the end user gets a more suitable hit list and can work more efficiently – see result section below.
In SAP TM when typing any value into a BP ID field the relevant search help is executed on the fly and up to 10 applicable entries are auto-proposed in a drop down. While you type the search help is executed again and again and hence refines the hit list as you type. This feature is called type ahead search. In TM systems based on HANA DB this is a fuzzy search against all available fields of the search help. In a non HANA DB system the search is against the ID only unless you followed the proposed configuration of the blog post Businesspartner-and-orgunit-search-in-sap-tm-uis/
In case the BPs of concern are all assigned to org units, then the search help results could be further refined as usually the base document (TRQ/TOR) has got an org. unit assigned by default.
This enhancement basically introduces a new separate search help, which can use the org unit as a selection criteria. The BP collective search help is enhanced to insert the new elementary SH and an enhancement is made to force the system to take this SH if needed – dependent on the context. It is just another use case for the already exposed UI context determination.
Details of the enhancement
The following steps are required:
- Copy the DB view /SCMTMS/H_BUPAA to your own one and adjust yours
- Copy the function /SCMTMS/SH_BUPA_COMMON to your own one and adjust yours
- Copy the search help /SCMTMS/BUPAA to your own one and adjust yours
- Create an append SH for /SCMTMS/CSH_BUPA (in the GOTO menu option – F5
- Enhance the standard function /SCMTMS/CSH_BUPA_COMMON (SH exit of collective SH)
- Adjust the code for relevant UI config and/or relevant BP roles
- In case you use the “combined search” customzing, add your SH
Ad 1) Copy the DB view /SCMTMS/H_BUPAA to your own one and adjust yours
1a) Add the DB table /SCMB/D_BPTMORG and add the join conditions. See screenshot.
1b) Add the view fields org, org_function, eikto. See screenshot.
Ad 2) Copy the function /SCMTMS/SH_BUPA_COMMON to your own one and adjust yours
Remove the old code and add your code.
DATA: lo_fpm TYPE REF TO if_fpm, lo_fbi TYPE REF TO /bofu/if_fbi_controller_new, ls_fpm_runtime_info TYPE fpm_s_runtime_info, lt_sh_selopt TYPE ddshselops, ls_sh_selopt TYPE ddshselopt, lt_shlp_tab TYPE shlp_desct, lt_selopt_rcode TYPE /scmtms/t_string_range, lt_selopt_roles TYPE /scmtms/t_string_range, ls_selopt_rcode TYPE /scmtms/s_string_range, ls_root_key TYPE /bobf/s_frw_key, lt_root_key TYPE /bobf/t_frw_key, lt_trq_data TYPE /scmtms/t_trq_root_k, lv_sales_org_relevant. FIELD-SYMBOLS: <ls_sh_selopt> TYPE ddshselopt, <ls_selopt_roles> TYPE /scmtms/s_string_range, <ls_trq_root_data> TYPE /scmtms/s_trq_root_k, <lt_any_node_data> TYPE INDEX TABLE, <ls_selopt> TYPE ddshselopt, <ls_interface> TYPE ddshiface. CHECK callcontrol-step = 'PRESEL' AND shlp-shlpname = 'ZSTF_BUPAA_ORG'. *---------------------------------------------------------------------------* * enable the combined search customizing for a non HANA based search lt_shlp_tab = shlp_tab. /scmb/cl_tya_sh_helper=>set_type_ahead_search_criteria( CHANGING ct_shlp_tab = lt_shlp_tab cs_shlp = shlp cs_callcontrol = callcontrol ). shlp_tab = lt_shlp_tab. *---------------------------------------------------------------------------* * translate the party role codes as in the standard SH exit LOOP AT shlp-selopt ASSIGNING <ls_sh_selopt> WHERE shlpfield = 'PARTY_RCO'. * recognize here which partner ID shall be used as selection criteria * => table /SCMTMS/V_PA_ROL CASE <ls_sh_selopt>-low. WHEN '1' " ordering party- OK OR 'TM002' " prepaid agreement party- OK OR '6' " shipper - OK OR '10' " bill-to - OK OR 'TM003' . " prepaid bill-to - OK lv_sales_org_relevant = abap_true. WHEN OTHERS. * any other org unit ? - e.g. purchase org for carrier ENDCASE. MOVE-CORRESPONDING <ls_sh_selopt> TO ls_selopt_rcode. INSERT ls_selopt_rcode INTO TABLE lt_selopt_rcode. DELETE shlp-selopt. ENDLOOP. IF sy-subrc NE 0. * temporary workaround - fast order entry screens do not set the role code * ==> this elementary SH is currently only called if it is sales org relevant ls_selopt_rcode-sign = 'I'. ls_selopt_rcode-option = 'EQ'. ls_selopt_rcode-low = '1'. INSERT ls_selopt_rcode INTO TABLE lt_selopt_rcode. lv_sales_org_relevant = abap_true. ENDIF. CALL METHOD /scmtms/cl_bupa_sh_helper=>get_roles_for_party_rco EXPORTING it_selopt_rcodes = lt_selopt_rcode IMPORTING et_selopt_roles = lt_selopt_roles. LOOP AT lt_selopt_roles ASSIGNING <ls_selopt_roles>. ls_sh_selopt-shlpname = 'ZSTF_BUPAA_ORG'. ls_sh_selopt-shlpfield = 'RLTYP'. MOVE-CORRESPONDING <ls_selopt_roles> TO ls_sh_selopt. INSERT ls_sh_selopt INTO TABLE shlp-selopt. ENDLOOP. * assuming this piece of code is only executed from UI and not in batch mode... CHECK sy-batch IS INITIAL. lo_fpm = cl_fpm_factory=>get_instance( ). lo_fbi ?= /bofu/cl_fbi_controller_new=>get_instance( ). ls_fpm_runtime_info = lo_fpm->get_runtime_info( ). * get the current instance lt_root_key = lo_fbi->mo_connector->mo_source_entity->get_self_keys( ). READ TABLE lt_root_key INTO ls_root_key INDEX 1. CHECK sy-subrc = 0. * read data of current instance directly from buffer or via retrieve via BOBF transaction manager READ TABLE lo_fbi->mt_node_buffer ASSIGNING FIELD-SYMBOL(<ls_node_buffer>) WITH KEY bo_key = /scmtms/if_trq_c=>sc_bo_key node_key = /scmtms/if_trq_c=>sc_node-root. IF sy-subrc EQ 0. ASSIGN <ls_node_buffer>-t_data->* TO <lt_any_node_data>. * ... depending from which UI the BP search is triggered: IF ls_fpm_runtime_info-config_id = '/SCMTMS/FWD_ORDER_OCEAN' AND "just an example lv_sales_org_relevant = abap_true. * here we know - it's a TRQ instance (as we know from which UI it is called) lt_trq_data = <lt_any_node_data>. READ TABLE lt_trq_data ASSIGNING <ls_trq_root_data> WITH KEY key = ls_root_key-key. IF sy-subrc EQ 0. * add the Sales Org as selection criteria IF NOT <ls_trq_root_data>-sales_org_id IS INITIAL. INSERT INITIAL LINE INTO TABLE shlp-selopt ASSIGNING <ls_selopt>. <ls_selopt>-shlpname = 'ZSTF_BUPAA_ORG'. <ls_selopt>-shlpfield = 'ORG'. <ls_selopt>-sign = 'I'. <ls_selopt>-option = 'EQ'. <ls_selopt>-low = <ls_trq_root_data>-sales_org_id. ENDIF. ENDIF. ENDIF. ENDIF.
Ad 3) Copy the search help /SCMTMS/BUPAA to your own one and adjust yours
3a) Add the org fields – see screenshot
3b) Add your view (step 1) as selection method
3c) Add your function (step 2) as search help exit
3d) Adjust the List-Position (LPos) sequence as required – see my proposal
Ad 4) Create an append SH for /SCMTMS/CSH_BUPA (in the GOTO menu option – F5)
4a) Include your copied elementary SH (step 4) -> “ZSTF_BUPAA_ORG”
4b) Maintain the assignment of UI fields – see screenshot
Ad 5) Enhance the standard function /SCMTMS/CSH_BUPA_COMMON (SH exit of collective SH)
This is required in order to make sure your elementary SH ist used if required and only then.
You need to do that as pre-exit.
DATA: lo_fpm TYPE REF TO if_fpm, ls_fpm_runtime_info TYPE fpm_s_runtime_info, lv_sales_org_relevant. FIELD-SYMBOLS: <ls_sh_interface_partner> TYPE ddshiface, <ls_sh_interface> TYPE ddshiface. IF sy-uname = 'FOERSTER'. * for the type ahead search: * - out of the available elementary SHs of the collective SH pick the address/Org search if required IF cl_web_dynpro=>valuehelpinfo-valuesuggest = abap_true. lo_fpm = cl_fpm_factory=>get_instance( ). ls_fpm_runtime_info = lo_fpm->get_runtime_info( ). * ... depending from which UI the BP search is triggered: IF ls_fpm_runtime_info-config_id = '/SCMTMS/FWD_ORDER_OCEAN'. "just an example * recognize already here whether the party role is relevant for the sales org assignment * and hence whether at all the special search help shall be used READ TABLE shlp-interface ASSIGNING <ls_sh_interface> WITH KEY shlpfield = 'PARTY_RCO'. IF sy-subrc = 0. CASE <ls_sh_interface>-value. WHEN '1' " ordering party- OK OR 'TM002' " prepaid agreement party- OK OR '6' " shipper - OK OR '10' " bill-to - OK OR 'TM003'. " prepaid bill-to - OK lv_sales_org_relevant = abap_true. WHEN OTHERS. * no reason to use the sales org assignment ENDCASE. IF lv_sales_org_relevant = abap_false. * in the fast order entry screens, the role code is not set... ? => bug * temporary work around: READ TABLE shlp-interface ASSIGNING <ls_sh_interface_partner> WITH KEY shlpfield = 'PARTNER'. IF sy-subrc = 0. CASE <ls_sh_interface_partner>-valfield. WHEN 'ORDER_PARTY_ID' . " ordering party- OK <ls_sh_interface>-value = '1'. lv_sales_org_relevant = abap_true. when 'SHIPPER_ID' . " shipper - OK <ls_sh_interface>-value = '6'. lv_sales_org_relevant = abap_true. WHEN OTHERS. * no reason to use the sales org assignment ENDCASE. ENDIF. ENDIF. IF lv_sales_org_relevant = abap_true. DELETE shlp_tab WHERE shlpname NE 'ZSTF_BUPAA_ORG'. EXIT. " no other SH shall be used but this one ENDIF. ENDIF. ENDIF. ENDIF. ENDIF.
Ad 6) Adjust the code for relevant UI config and/or relevant BP roles
In the provided code adjust / add the right UI configuration(s), for which the type ahead search shall be applied. Also adjust / add the right BP role codes, which are relevant for the sales org based search.
Ad 7) In case you use the “combined search” customzing in your non-HANA-DB system (as explained in blog Businesspartner-and-orgunit-search-in-sap-tm-uis), then copy the /SCMTMS/BUPAA customizing entries to your elementary SH (of step 3).
Result => improved user efficiency
Comprehensive FWO view: Without the enhancement
But: Sales Org assignment available…
Comprehensive FWO view: With the enhancement in place => only the sales org relevant BP comes
Fast order entry screen: Without the enhancement
Fast order entry screen: With the enhancement in place => only the sales org relevant BP comes