Application Development 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: 

ABAP string functions

Former Member
0 Kudos

What is the ABAP code to find the last three characters of a string?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

data : a type string,b type i,c type string,d type i.

a = 'abcdefghi'.

b = strlen( a ). "9

d = b - 3. "6

c = a + d(3). "ghi

write :confused_face: c.

10 REPLIES 10

Former Member
0 Kudos

hi,

data : lv_string type string.

to get last 3 characters use the code

lv_string + 3.

Former Member
0 Kudos

data : a type string,b type i,c type string,d type i.

a = 'abcdefghi'.

b = strlen( a ). "9

d = b - 3. "6

c = a + d(3). "ghi

write :confused_face: c.

Former Member
0 Kudos

Hi,

var1 = STRLEN(var)

var2 = var1 - 3

var+var2(var1) would give you the lst three characters

Pankaj

Thomas8
Active Contributor
0 Kudos
SHIFT lf_string RIGHT CIRCULAR BY 3 PLACES.
WRITE lf_string(3).

Former Member
0 Kudos

Thanks.. It worked

0 Kudos

This message was moderated.

Former Member
0 Kudos

Use FM 'STRING_REVERSE'. Reverse your string and select first 3 characters

0 Kudos

but then the content is backwards, e.g. "ramuk hsekum"!

you'd have to put the result into STRING_REVERSE again to get the actual sequence.

Edited by: Aravinda A Hegde on Jul 27, 2009 3:02 PM

Former Member
0 Kudos

data: c TYPE string VALUE 'this is string',

c1(3),

len TYPE i.

len = STRLEN( c ).

len = len - 3.

c1 = c+len(3).

WRITE / c1.

try this

Edited by: mayank jain on Jul 27, 2009 1:03 PM

0 Kudos

Thanks, this was useful.