SAP LENGTH FUNCTIONS



Get Example source ABAP code based on a different SAP table
  


• charlen ABAP_FUNCTION
• dbmaxlen ABAP_FUNCTION
• numofchar ABAP_FUNCTION
• strlen ABAP_FUNCTION

ABAP_STRINGFUNC - charlen, dbmaxlen, numofchar, strlen
These built-in length functions have an unnamed character-like argument.

ABAP_SYNTAX
... func( arg ) ...

What does it do?
The following table shows the length functions with an unnamed argument. The arguments arg of all length functions except dbmaxlen are character-like expression positions. The argument of dbmaxlen is a character-like functional operand position. The return value has the type i for all length functions. Function <(>func<)>Return Value ABAP_KEY charlenLength of the first character of arg in the code page used: 1 for a single Unicode character; 2 for surrogate pairs. ABAP_KEY dbmaxlenMaximum length of a string defined in the ABAP Dictionary (RAWSTRING, SSTRING, STRING, or GEOM_EWKB). If the string is unrestricted, the constant abap_max_db_string_ln or abap_max_db_rawstring_ln from the type pool ABAP is returned. The latter is also returned for the built-in ABAP types string and xstring. ABAP_KEY numofcharNumber of characters in arg, where trailing blanks are neither counted in data objects with fixed lengths nor in data objects with the type string. ABAP_KEY strlenNumber of characters in arg, where trailing blanks in data objects with fixed lengths are not counted, whereas in data objects with the type string they are.



Latest notes:

NON_V5_HINTS
The functions listed here are some of the functions that can also be used in the obsolete extended functional operand positions if their argument is a single data object.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The results of the following length determinations are 10 and 5.
ABEXA 01069
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The result of function strlen is 2 because ABAP handles the surrogate pair in the character string as two UCS-2 characters. When counting with a regular expression in PCRE syntax that is introduced with (*UTF), the result is 1, because the surrogate pair is interpreted as one UTF-16 character.
ABEXA 01491
ABAP_EXAMPLE_END