What’s in this document
This document describes how to configure Fuzzy Search in Search Help using CDS Views for ABAP. This feature is available in SAP NetWeaver 7.4 SP5 and higher.
The objective of this document is show, how easy it is to configure fuzzy search in Search Help ABAP Object with zero coding.
SAP HANA allows fast search access to character based columns. Fuzzy Search is a fast and fault-tolerant search feature for SAP HANA. A fuzzy search returns records even if the search term contains additional or missing characters or other types of spelling errors. That can be very helpful in F4 Search Helps or duplicate checks.
The traditional way of implementing the fuzzy search logic in Search Help mandates implementing a function module and assigning the same as Search Help Exit of the Search Help. The fuzzy search logic of course should then be implemented using Native SQL [ADBC] since it is a HANA specific feature. However, from SAP NetWeaver AS ABAP 7.4 SP05 onwards, Search Help Dictionary Object provides an additional option – Enhanced Options – where you can configure fuzzy search options [like accuracy value, cross column options etc.]. This eliminates the need of implementing function module to achieve in such scenarios.
Technical Background Information
Search helps can be used to assign an input help (F4 help) to screen fields. The user can display the list of all possible input values for a screen field with the input help.
There are several types of Search help such as:
- Elementary search helps: This type implements a search path for determining the possible entries.
- Collective search helps: This type contains several elementary search helps. A collective search help therefore provides several alternative search paths for possible entries.
- Append search helps: This type can be used to enhance collective search helps delivered by SAP with customer-specific search paths without requiring a modification.
Core Data Services (CDS) for ABAP
Core Data Services (CDS) enhanceSQL to allow defining and consuming semantically rich data models, thereby improving consumption, performance and interoperability. CDS simplifies and harmonizes the way you define and consume your data models, regardless of the consumption technology. CDS in ABAP provides you with a data definition language (DDL) for defining semantically rich database tables/views (CDS entities) and user-defined types in the database.
For several years for now, it is possible to define views in the ABAP Dictionary, but these views are quite restricted. For example, you can only define inner join for database views. Outer joins are available only for help and maintenance views. However, it is not possible to perform aggregations in views or define nested views. With ABAP 7.4 SP05, a new editor is available to define views directly in the Eclipse-based ABAP development environment. With this Source-based editor you can define CDS entities, which can be consumed in ABAP programs using Open SQL.
The CDS View building provides another way of code pushdown using features that are similar as in Open SQL. With CDS View building it is possible to define:
- Projections, aggregations, and groupings
- Use expressions (like CASE), SQL built-in functions
- UNION and UNION ALL and non-equi INNER JOINs
Nesting of Views with associations between the View entities (associations can be consumed in the WHERE clause as well as in expression in Open SQL queries).
Before getting started, you must generate data related to Enterprise Procurement Model (EPM). You can use the transaction SEPM_DG_OIA to generate
the data for EPM model. For more information about EPM, see http://scn.sap.com/docs/DOC-31458
For creating search help, use the CDS view SEPM_CDS_OPEN_INVOICE_REDUCED. The ABAP view name of this CDS view is EPMAPPS_CDS_OIR.
This CDS view is part of the package S_EPM_OIA_APPS_PROVIDER. This CDS View fetches all the Open Sales Orders – sales orders whose payment is
yet to be made by the Buyers. Buyer Name, Dunning Level, Overdue Invoice Amount, Currency are some of the details retrieved for each of the Sales Order.
Below is the structure of the CDS view [SEPMAPPS_CDS_OIR].
The steps to implement fuzzy search logic in CDS view [SEPMAPPS_CDS_OIR] using “Enhanced Options“ in Search Help are described below:
- Create a Search Help [ZH_EPM_OIA_SO] using the SE11 transaction. Make sure it is an Elementary Search Help.
- Enter the name of the CDS view name [SEPMAPPS_CDS_OIR] in “Selection method” input field.
- Use the “Enhanced Options” section to configure the fuzzy search options [Refer screenshot given in step 4].
- Create Search help parameters such as SO_ID and COMPANY_NAME and mark them as importing parameter, if you want to search for both company_name and so_id. You can also mark both the parameters as exporting parameters, if you want to display both, company_name and so_id, as output of the fuzzy search as shown in the snapshot below.
- Currently, the SE11 transaction does not support enhanced options in the test mode. You need to test them in a normal screen or by using a report with the type-ahead API.Attached is the source for the report, ZDSH_DYNAMIC_TYPE_AHEAD_SHLP, to test the search Help.
- Execute the report ZDSH_DYNAMIC_TYPE_AHEAD_SHLP created in step 5 above.
- Enter the following: ZH_EPM_OIA_SO in the PA_SHLP field, * in the PA_FLD field and the search string “oi” in the PA_REQ field and click on the Execute button.
- Fuzzy search displays the type-ahead for the search string “oi”.
Note: Enhanced Options available in Search Help work only with DDIC tables and CDS view. Currently, Enhanced Options does not support the usage of external view.