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: 

help

Former Member
0 Kudos

Hi,

How to get the last character of character value? for example: '1226262M', I wanna get the suffix 'M'. Length of the character can be varying.

Many thanks.

Alia

1 ACCEPTED SOLUTION

vladimir_golovtchiner
Participant
0 Kudos

Hi,

try that:

data: len type i,

result(1).

parameters word(20).

len = strlen( word ) - 1.

result = word+len(1).

write result.

best regards

Vladimir

6 REPLIES 6

Former Member
0 Kudos

Hi,

Alia can you be much clear plzzzz.

Why means Length of the character or charecter no is varying?

Thanks.

vladimir_golovtchiner
Participant
0 Kudos

Hi,

try that:

data: len type i,

result(1).

parameters word(20).

len = strlen( word ) - 1.

result = word+len(1).

write result.

best regards

Vladimir

Former Member
0 Kudos

use fm STRING_REVERSE and take 1st character from result.

Former Member
0 Kudos

hi,

data i type i,

data x(15) type c,

y type c,

x = '1226262M'

i = strlen( x )

i = i - 2.

y = x+i(1).

cheers,

sasi

Former Member
0 Kudos

Hy Alia

you can use the command strlen to get the length of the string.

len = strlen(your_string).

and then use SHIFT.

I put some example code.

data len type i.

data my_string type string value '1226262M'.

len = strlen( my_string ).

len = len - 1.

shift my_string by len.

that's all. In my_string variable you'll have 'M'.

By enzo

animesh_kumar2
Active Participant
0 Kudos

Hi,

there are many string manipulation functions so take a look of them first, u will get many ways to do this.

You can measure the length of the string through strlen() function and then shift your string length - 1 place and you will get the desired value.

you can use this:

data: a type string value '1226262M'.

data: b type i.

b = strlen( a ) - 1.

shift a by b places.

write /: a.

Regards,

Animesh