‎2007 Jun 01 9:41 AM
in abap?
I want to get the length of a chararcter field but not with blanks. I just want the characters?
Thank you.
Deniz.
‎2007 Jun 01 9:45 AM
data: v_len type string.
v_len = v_cah.
condense v_len no-gaps.
n = strlen ( v_len ).
Regards,
Amit
Reward all helpful replies.
‎2007 Jun 01 9:44 AM
‎2007 Jun 01 9:45 AM
data: v_len type string.
v_len = v_cah.
condense v_len no-gaps.
n = strlen ( v_len ).
Regards,
Amit
Reward all helpful replies.
‎2007 Jun 01 9:45 AM
You can use :
CONDENSE <string> NO-GAPS.
And then find out string lengh by strlen(<string>).
‎2007 Jun 01 9:46 AM
data : text(50) value 'I want the string length'.
data : len type i.
condense text no-gaps.
len = strlen( text ).
write : / len.
for getting the individual character you have to use do enddo.
regards
shiba dutta
Message was edited by:
SHIBA DUTTA
‎2007 Jun 01 9:47 AM
Hi Deniz,
from SAP HELP.
Variant 4
SHIFT c LEFT DELETING LEADING c1.
Variant 5
SHIFT c RIGHT DELETING TRAILING c1.
Effect
(Variant 4/variant5). Shifts the contents of c to the left or right for as long as the string begins or ends with a character contained in c1.
If c does not begin or end with a character from c1, it remains unchanged.
Example
DATA: ALPHABET(15) VALUE ' ABCDEFGHIJ',
M1(4) VALUE 'ABCD',
M2(6) VALUE 'BJJCA '.
SHIFT ALPHABET LEFT DELETING LEADING M1.
The field ALPHABET remains unchanged.
SHIFT ALPHABET LEFT DELETING LEADING SPACE.
The field ALPHABET now has the following contents:
'ABCDEFGHIJ '.
SHIFT ALPHABET RIGHT DELETING TRAILING M2.
ALPHABET now has the following contents:
' ABCDEFGHI'.
Note
Performance:
For performance reasons, you should avoid using SHIFT in WHILE loops.
The runtime required to shift a field with length 10 by one character to the right or left requires about 5 msn (standardized microseconds). A cyclical shift requires around 7 msn. The runtime for the ... LEFT DELETING LEADING ... variant is around 3.5 msn, for ...RIGHT DELETING TRAILING... around 4.5 msn.
Regards,
Jayant.
‎2007 Jun 01 10:00 AM
Hi Deniz,
Try this....
DATA: X(10) TYPE C.
X = <VARIABLE>.
CONDENSE X NO-GAPS.
N = STRLEN( X).
Regards,
Younus
<b>Reward Helpful Answers:-)</b>