CONDENSE (ABAP Keyword)

CONDENSE (ABAP Keyword) introduction & details

CONDENSE

Basic
form
CONDENSE c.

Addition


NO-GAPS

Effect
Shifts the contents of the field c to the left, so
that each word is separated by exactly one blank.

Example

DATA:
BEGIN OF NAME,
TITLE(8), VALUE ‘Dr.’,
FIRST_NAME(10), VALUE
‘Michael’,
SURNAME(10), VALUE ‘Hofmann’,
END OF NAME.
CONDENSE
NAME.
WRITE NAME.

produces the output:

Dr. Michael
Hofmann

Addition
… NO-GAPS

Effect
Suppresses all blanks
from the field c

Example

DATA: BEGIN OF NAME,
TITLE(8), VALUE
‘Dr.’,
FIRST_NAME(10), VALUE ‘Michael’,
SURNAME(10), VALUE
‘Hofmann’,
END OF NAME.
CONDENSE NAME NO-GAPS.

The contents of
NAME is now ” Dr.MichaelHofmann “.

Since the field string NAME is
interpreted and handled like a type C field, the CONDENSE statement treats it as
a whole and ignores any sub-fields. The contents of the component field would
therefore now be as follows:

NAME-TITLE = ‘Dr.Micha’
NAME-FIRST_NAME =
‘elHofmann ‘
NAME-SURNAME = ‘ ‘

Note
Do not use CONDENSE to
manipulate field strings that include fields not of type C. This could result in
these component fields containing characters of a different (i.e. incorrect)
type.
Related SHIFT , CONCATENATE , REPLACE ,
SPLIT

Note
Performance
The runtime required to condense three
fields is about 20 msn (standardized micooseconds). The variant … NO-GAPS
needs about 12 msn.