How to get last letter of a string in ABAP SAP

get last letter from String in SAP



How to get last letter of a string in ABAP SAP


In this post, we will  learn how to get last letter of a string in ABAP SAP.

1. get the length of the string and subtract 1.
2. use offset to get the letter.

For Example:


Data: String type char20.
Data: lenght type i.
Data: last_letter type c.
Data: last_3_letter type char3.

length = strlen( string ) - 1.
last_letter = string+length(1).
length = length - 2.
last_3_letter = string+length(+3).
Share on Google Plus

About JK STACK

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

3 comments: