2007 Apr 25 1:02 PM
Hi guys.
Have a problem with ABAP in SAP.
I need to get the last character of the string, like this...
'AAAAAAAA BBBB 1 QQQQQQQQ 2'.
i need to take the last letter (2) to do more things b4.
I'm thinking to rotate the string and take the first letter, but i think will exist a FM that do my requirement.
See you.
Thanks: Miguel
2007 Apr 25 1:45 PM
Hi,
use below logic
str = 'test'.
data a type i.
a = strlen(str).
write str(a).
Regards
Amole
2007 Apr 25 1:05 PM
name = 'PRABHU'.
n = strlen(name).
n = n - 1. (n = 5)
output = name+n(1) = U.
Regards
Prabhu
2007 Apr 25 1:05 PM
one long way is
first use STRING_LENGTH FM , then subtract 1 from length
then use STRING_SPLIT_AT_POSITION and pass the length previously calculated
2007 Apr 25 1:09 PM
use the below code.
data : l_length type i,
l_data(50).
l_data = 'AAAAAAAA BBBB 1 QQQQQQQQ 2'.
l_length = STRLEN( l_data ) . " here u will get the length of the field l_data.
by using the length read your variable l_data
and get the last 2 records
2007 Apr 25 1:10 PM
Hi,
First get the string lengthof the variable.
data: lv_string type char4 value 'ABCD',
lv_new type i,
lv_new1 type char2.
*lv_new = strlen(lv_string).
CALL FUNCTION 'STRING_LENGTH'
EXPORTING
string = lv_string
IMPORTING
LENGTH = lv_new
.
lv_new = lv_new - 2.
lv_new1 = lv_string+lv_new(2).
write lv_new1.
You get the last two characters.
reward if useful..
regards,
nazeer
Message was edited by:
nazeer shaik
2007 Apr 25 1:21 PM
Miguel,
One way to do this is ,
find the string length by usinf strlen(strVariableName or String) command.
Find the string lenght-1 posotion of that string.
Regards,
<b>Ramganesan K</b>
2007 Apr 25 1:45 PM
Hi,
use below logic
str = 'test'.
data a type i.
a = strlen(str).
write str(a).
Regards
Amole
2007 Apr 25 1:50 PM
2007 Apr 25 1:56 PM
2007 Apr 25 3:07 PM
thanks everybody for your responses.
i like a lot the Amole solution.
thanks anyway.
see you SAPers
2020 Jan 18 4:01 PM
Hi, the top answer is not correct at all. If you don't mind the longer read, my blog post compares all the solutions from this page: https://blogs.sap.com/2020/01/18/how-to-retrieve-the-last-character-of-a-string-in-abap-definitive-e...