Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

is it available a function like trim

Former Member
0 Likes
776

in abap?

I want to get the length of a chararcter field but not with blanks. I just want the characters?

Thank you.

Deniz.

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
747

data: v_len type string.

v_len = v_cah.

condense v_len no-gaps.

n = strlen ( v_len ).

Regards,

Amit

Reward all helpful replies.

6 REPLIES 6
Read only

Former Member
0 Likes
747

Hi,

Your thread is answered here.

Thanks,

Anitha

Read only

amit_khare
Active Contributor
0 Likes
748

data: v_len type string.

v_len = v_cah.

condense v_len no-gaps.

n = strlen ( v_len ).

Regards,

Amit

Reward all helpful replies.

Read only

Former Member
0 Likes
747

You can use :

CONDENSE <string> NO-GAPS.

And then find out string lengh by strlen(<string>).

Read only

Former Member
0 Likes
747

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

Read only

Former Member
0 Likes
747

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.

Read only

Former Member
0 Likes
747

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>