‎2007 Mar 09 8:22 AM
Hai
I want to know what is difference between strlen and condense function
‎2007 Mar 09 8:37 AM
Hi Suneetha.....
The ABAP function <b>STRLEN</b> returns the length of a string up to the last character that is not a space.
The <b>CONDENSE</b> 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<b> NO-GAPS</b> is specified, all blanks are removed.
EX:
DATA: STR(20) VALUE ' Enjoy with SAP',
LEN TYPE I.
LEN = STRLEN( STR ).
WRITE : STR,LEN.
CONDENSE STR .
LEN = STRLEN( STR ).
WRITE: / STR , LEN.
CONDENSE STR NO-GAPS.
LEN = STRLEN( STR ).
WRITE: / STR , LEN.
Just Execute the above code u will understand
Suresh.....
‎2007 Mar 09 8:23 AM
Hi,
strlen will give string length.
Returns the length of a character-type field in characters. With c-fields, as opposed to fields with type STRING, only the actual length used is relevant because blanks at the end are not counted.
condense.
Shifts the content of the field c to the left, so that sequences of blanks are reduced to exactly one blank. Leading blanks are removed, as are trailing blanks in string type fields.
Example
DATA NAME (30).
NAME(10) = ' Dr.',
NAME+10(10) = 'Michael',
NAME+20(10) = 'Hofmann'.
CONDENSE NAME.
WRITE NAME.
displays the following:
Dr. Michael Hofmann
Regards,
Sruthi
‎2007 Mar 09 8:25 AM
strlen give the length of a string / char field it is giving the integer return like str length 3 or 4 like that.
condense will delete the spaces in the string/char field.
regards
shiba dutta
‎2007 Mar 09 8:25 AM
Strlen functions gives the number of character in a give character type variable...
Condense :
suppose u have a field of length 50 characters.. say w_char(50) type c.
and u have onli 20 characters of data in that variable ... u can use condense function to
print onli 20 characters for that field...i mean it deletes the remaining empty characters while printing..
U have one more option <b>condense w_char no-gaps</b>.
It removes all the gaps even the spaces in between the characters also...
reward help ful answers...
sai ramesh
‎2007 Mar 09 8:26 AM
Suneetha,
String length will give the length of the String.
where as Condense will reduce the gap existing in String...
see the details with examples..
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.
Pls. reward if useful
‎2007 Mar 09 8:29 AM
Hi,
CONDENSE <c> [NO-GAPS].
Removes leading blanks. Replaces other sequences of blanks with one blank or removes all blanks if NO-GAPS.
STRLEN * :
Function STRLEN only works with character-type fields and returns the length in characters. The new function XSTRLEN finds the length of byte strings.
[COMPUTE] <n> = STRLEN( <c> ).
Regards,
Sreevani
‎2007 Mar 09 8:37 AM
Hi Suneetha.....
The ABAP function <b>STRLEN</b> returns the length of a string up to the last character that is not a space.
The <b>CONDENSE</b> 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<b> NO-GAPS</b> is specified, all blanks are removed.
EX:
DATA: STR(20) VALUE ' Enjoy with SAP',
LEN TYPE I.
LEN = STRLEN( STR ).
WRITE : STR,LEN.
CONDENSE STR .
LEN = STRLEN( STR ).
WRITE: / STR , LEN.
CONDENSE STR NO-GAPS.
LEN = STRLEN( STR ).
WRITE: / STR , LEN.
Just Execute the above code u will understand
Suresh.....