SAP CONDENSE FUNCTIONS



Get Example source ABAP code based on a different SAP table
  


• condense ABAP_FUNCTION
• del condense function
• from condense function
• to condense function

ABAP_STRINGFUNC - condense

ABAP_SYNTAX
... condense( $[val =$] text $[del = del$] $[from = from$] $[to = to$] ) ...

What does it do?
This built-in function returns a condensed content of text. The function works as follows: First, all leading and trailing characters are removed, that are specified in del. If del is an empty string, no leading and trailing characters are removed. Second, in the remaining string all substrings composed of characters specified in from are replaced with the first character of the string specified in to. If from is an empty string, no characters are replaced. If to is an empty string, the characters specified in from are removed.
The default values for del, from, and to are one blank each. If neither del, from, nor to are specified, val = can also be omitted. Then, the condense function first removes any leading and trailing blanks and then all substrings of the remaining character string that contain nothing but blanks are replaced by exactly one blank.
del, from, and to are character-like expression positions. If these have a fixed length, trailing blanks are ignored.
The return value has the type string.



Latest notes:

Comparison with the CONDENSE statement:
When del, from, and to are not specified or their default values (one blank) are passed, the condense function works in the same way as the CONDENSE statement without the NO-GAPS addition.
When for del and from their default values (one blank) are passed and for to an empty string is passed, the condense function works in the same way as the CONDENSE statement with the NO-GAPS addition.
When using default values, the effect of condensing substrings containing nothing than blanks to one blank, comes from applying the default values for from and to and has nothing to do with the value of del.
For removing the leading and trailing blanks without affecting the remaining character string, you can use the default value for del and an empty string for from. The latter must be specified explicitly, because the default value (blank) causes substrings consisting of blanks to be replaced by the first character from to , which also is a blank.
Specifying a text field literal ' ' containing one blank for del, from, and to is the same as specifying `` but not the same as` ` `. Only the latter represents the default value.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The return values of the following functions are abc_def, abc___def, abcdef and abcXdef, where _ stands for a blank.
ABEXA 00881
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The return value of the following function call is Rock'n'Roll.
ABEXA 00882
ABAP_EXAMPLE_END