SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, code samples and tools and downloads for ASP.Net, SQL Server, R Script, Windows, Windows Phone, AWS, SAP HANA and ABAP, like SAP UI5, Screen Personas, etc.

Install SAP Free

ABAP Fuzzy Search for String Compare for SAP Developer

In ABAP for string compare using fuzzy search SAP developer has a list of ABAP function modules like ISH_STRING_COMPARE_FUZZY. This tutorial shows how fuzzy compare function module can be used in an ABAP program with sample codes.

Below is how ABAP function module ISH_STRING_COMPARE_FUZZY could be used to find the closest customer name to a given string variable among all other customer names in KNA1 table NAME1 field values.

ABAP function module ISH_STRING_COMPARE_FUZZY compares two strings and returns a hit probability between these two input variables.

DATA lv_searchfor TYPE char10 VALUE 'kodyaz'.
DATA lv_kunnr_max TYPE kunnr.
DATA lv_probability_max TYPE arch_int-fltp VALUE 0.
DATA lv_probability TYPE arch_int-fltp.
DATA lv_word_found TYPE char10.

SELECT kunnr, name1 FROM kna1 INTO TABLE @DATA(lt_names)
 UP TO 100000 ROWS.

LOOP AT lt_names REFERENCE INTO DATA(lr_names).

   search_for = lv_searchfor
   search_in = lr_names->name1
   probability = lv_probability
   word_found = lv_word_found.

 IF lv_probability_max < lv_probability.
  lv_probability_max = lv_probability.
  lv_kunnr_max = lr_names->kunnr.


IF lv_kunnr_max IS NOT INITIAL.
  lt_names[ kunnr = lv_kunnr_max ]-kunnr,
  lt_names[ kunnr = lv_kunnr_max ]-name1.

ABAP program codes for developers

SAP fuzzy search code in ABAP for string compare

The output of this ABAP program will be the customer number and name which is the most similar value to a given string value.

SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table

Meetup Sunumu 1 meetup

Copyright © 2004 - 2020 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems