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

truncate last 3 chatechter from a string

Former Member
0 Likes
3,625

i want to show the last 3 charecter from a string ,

how do i do that

1 ACCEPTED SOLUTION
Read only

sachin_mathapati
Contributor
0 Likes
2,858

Hi,

Try this,

DATA : wf_len type c.

wf_len = strlen(wf_string).

Wf_len = wf_len - 3.

write : wf_string+wf_len(3).

Regards,

Sachin M M

Edited by: Sachin Mathapati on Sep 9, 2008 3:30 PM

Hi,

Try this,

DATA : wf_len type c.

wf_len = strlen(wf_string).

Wf_len = wf_len - 3.

write : wf_string+wf_len(3).

Regards,

Sachin M M

Edited by: Sachin Mathapati on Sep 9, 2008 3:30 PM

10 REPLIES 10
Read only

sachin_mathapati
Contributor
0 Likes
2,859

Hi,

Try this,

DATA : wf_len type c.

wf_len = strlen(wf_string).

Wf_len = wf_len - 3.

write : wf_string+wf_len(3).

Regards,

Sachin M M

Edited by: Sachin Mathapati on Sep 9, 2008 3:30 PM

Read only

peter_ruiz2
Active Contributor
0 Likes
2,858

hi Atiul,

use this


data v_len type p.

v_len = strlen( v_string ).

subtract 3 from v_len.

write: v_string+v_len(3).

regards,

Peter

Read only

Former Member
0 Likes
2,858
Read only

Former Member
0 Likes
2,858

DATA a TYPE string VALUE 'satharra'.

data b TYPE i .

b = STRLEN( a ).

b = b - 3.

WRITE a+b(3).

Read only

Former Member
0 Likes
2,858

try it this way:

Data:
  w_string type string,
  w_strlen type i.

w_string = 'abcdecbsjdbjkl'.

w_strlen = strlen( w_string ).

w_strlen = w_strlen - 3.

w_string = w_string+w_strlen(3).

Write:
  w_string.

Regards and luck,

Pritam.

Read only

Former Member
0 Likes
2,858

Hi,

Data:

w_name type string,

w_str type i.

w_name = 'atiul eshan'.

w_str = str( w_name ).

w_str = w_str - 3.

w_name = w_name+w_str(3).

Write:

w_name.

Regards,

Sravanthi

Read only

Former Member
0 Likes
2,858

Hi,

RIGHT(@SHORT_TEXT,3)

Displays the last three characters of the string. For example, a value of FINALCOST would be displayed as OST.

Hope that helps.

Regards,

Surinder

Read only

Former Member
0 Likes
2,858

Hi,

data: name type char length 10.

data: len type i.

name = 'sap.sdn'.

len = strlen(name).

len = len - 3.

name1 = name0(len).

write: name1.

Read only

Surendra_Karma
Participant
0 Likes
2,177

SUBSTRING function could be the best way.

DATA(lv_string) =  'ABCD1234.xls'. "dummy string
DATA(lv_ftype) = substring( val = lv_string off = ( strlen( lv_string ) - 3 ) len = 3 ). "to get "xls" (last 3 characters)
Read only

0 Likes
2,091

 

write: / xco_cp=>string( `ABCD1234.xls` )->to( -3 )->value.