sapdev logo background
sapdev logo sapdev logo
Comments

SAP DISTANCE FUNCTIONS documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

distance - Distance Function

Syntax
... distance( val1 = text1 val2 = text2 [max = max] ) ...

Effect
This function returns the Levenshtein distance between two strings text1 and text2 . This distance is the minimum number of insert, delete, and replace operations required to change one string to another and hence reflects the similarity of the two strings. The return value has the type i .
You can use max to declare a positive value other than 0; the calculation of the Levenshtein distance is canceled if the distance is greater than max . The value of max is returned instead. max is a numerical expression position of the type i . If the value of max is less than or equal to 0, an exception of the class
CX_SY_STRG_PAR_VAL is raised. If max is not specified, the calculation is not terminated

Notes
  • The complexity of the function increases in line with the product of the lengths of the two strings. You can limit the calculation time by declaring max .

  • One typical application of this function is to find a word in a word set that is most similar to a word entered in a search.


  • Example
    See Character String Functions, distance



    Runtime Exceptions

    Catchable Exceptions
    CX_SY_STRG_PAR_VAL
    Reason for error: Value in max is less than or equal to 0.
    Runtime error: STRG_ILLEGAL_PAR
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved








    comments powered by Disqus