Show TOC

Condensing Field ContentsLocate this document in the navigation structure

The CONDENSE statement deletes redundant spaces from a string:

CONDENSE c [NO-GAPS].

This statement removes any leading blanks in the field c and replaces other sequences of blanks by exactly one blank. The result is a left-justified sequence of words, each separated by one blank. If the addition NO-GAPS is specified, all blanks are removed.

Tip

DATA: string(25) TYPE c VALUE ' one  two   three    four',      len TYPE I.

len = strlen( string ).WRITE: string, '!'.WRITE: / 'Length: ', len.

CONDENSE string.len = strlen( string ).WRITE: string, '!'.WRITE: / 'Length: ', len.

CONDENSE string NO-GAPS.len = strlen( string ).WRITE: string, '!'.WRITE: / 'Length: ', len.

Output:

one  two   three    four !

Length:          25

one two three four        !

Length:          18

onetwothreefour           !

Length:          15

Note that the total length of the field string remains unchanged, but that the deleted blanks appear again on the right.