05-09-2007 4:21 PM
05-09-2007 4:24 PM
Hi Vijay
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.
DATA: STRING(25) 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.
Regards Rk
05-09-2007 4:23 PM
Hello,
Syntaxdiagramm
CONDENSE
Basic form
CONDENSE c.
Addition:
... NO-GAPS
Note
Like all string processsing statements, you can only use character-type operands here.
If the type of an operand is not STRING, the operand is treated like a type C field, regardless of its actual type, even though no actual conversion takes place.
In an ABAP Objects context, a more severe syntax check is performed that in other ABAP areas. See Only character fields allowed in string processing.
Effect
Shifts the contents of c to the left, so that sequences of blanks are reduced to exactly one blank. Leading spaces (and, for type C fields, trailing spaces as well), are removed completely.
Example
DATA NAME (30).
NAME(10) = ' Dr.',
NAME+10(10) = 'Michael',
NAME+20(10) = 'Hofmann'.
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 sub-field would therefore now be as follows:
NAME-TITLE = 'Dr.Micha'
NAME-FIRST_NAME = 'elHofmann '
NAME-SURNAME = ' '
Note
Do not use CONDENSE to manipulate structures that include fields not of type C. This could result in the subfields containing characters of a different (i.e. incorrect) type. You cannot use the statement with structures containing components of type STRING.
Note
Performance:
The runtime required to condense three fields is about 20 msn (standardized microseconds). The variant ... NO-GAPS needs about 12 msn.
Related
SHIFT, CONCATENATE, REPLACE, SPLIT
Additional help
Compressing Field Contents
Once ur problem is solved reward the points and close the thread.
Vasanth
05-09-2007 4:24 PM
Hi Vijay
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.
DATA: STRING(25) 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.
Regards Rk
05-10-2007 2:44 PM
Hi,
its for Suppresses all blanks from the field of type CHAR,
reward points and close the thread.
Cheers,
Harish
Message was edited by:
Harish AGINATI
05-15-2007 1:49 PM
hi
Removes spaces from a string.
<b>Syntax</b>
CONDENSE <c> [NO-GAPS].
Removes all leading spaces, and replaces other series of blanks with a single space in the character field <c>. If you use the NO-GAPS addition, all of the spaces are removed.
REWARD IF USEFUL...