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

select last characters

Former Member
0 Likes
2,467

Hi.

In a fied i need the last 10 characters but i don´t know the leght of the field.

Any idea.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,807

Hi,

Please try this FM ACEPS13_AWKEY_DECODE.

<b>Reward points</b>

Regards

11 REPLIES 11
Read only

Former Member
0 Likes
1,807

use describe statment to know the length of the field

DESCRIBE FIELD f

Read only

Former Member
0 Likes
1,807

Hello,

Do like this.


data: char(20) value 'select last characters',
         len type i.
len  = strlen ( Char).
len = len - 10.
write: char+len(10).

Vasanth

Read only

Former Member
0 Likes
1,807

Hi

get the length of the same using STRLEN.

subtarct the toatl length - 10.

then use the offset method and pass the value

then pass the val;ue of this as offset and value as 10

Regards

Shiva

Read only

Former Member
0 Likes
1,807

data : len type i,

text(40) value 'abcdefghijklmon',

ntext(10).

compute len = strlen( text ).

len = len - 10.

ntext = text+len(10).

write : / ntext.

regards

shiba dutta

Read only

Former Member
0 Likes
1,808

Hi,

Please try this FM ACEPS13_AWKEY_DECODE.

<b>Reward points</b>

Regards

Read only

Former Member
0 Likes
1,807

Use the to STRLEN( <c> ).get the lenght of the field

lv_len = STRLEN( <c> ).

Read only

Former Member
0 Likes
1,807

The field is a type string and the content can to be variable.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,807

Hi,

Check this can help you.

DATA: FLD(8),

LEN TYPE I.

DESCRIBE FIELD FLD LENGTH LEN IN CHARACTER MODE.

Result: LEN contains the value 8.

Read only

0 Likes
1,807

REPEAT: The variable is a type string and the before code not is accept.

Read only

0 Likes
1,807

HI,

This will work.. irrespective of the length..

data: char(20) value 'select last characters',

len type i.

len = strlen ( Char).

if len > 10.

len = len - 10.

write: char+len(10).

else

write char.

endif.

Thanks

Mahesh

Read only

0 Likes
1,807

I modified Mahesh's code a bit:

DATA: char  TYPE string VALUE 'select last characters',
len TYPE i.
len = STRLEN( char ).
IF len > 10.
  len = len - 10.
  WRITE: char+len(10).
ELSE.
  WRITE char.
ENDIF.

Rob