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

trancating a field string

Former Member
0 Likes
608

hi

i have a field string <field_TEXT> with value 123145-12300

now i need to get the last five digits of the value i have

i.e i need 12300 only to be taken into another variable

how can i do that

regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
585

Hi Vamsi,

U can use the following:

data : str1 type string value '123145-12300',

len type i,

off type i,

str2 type string.

len = strlen(str1).

off = len - 5.

str2 = str1+off(5).

this will populate str2 with 12300.

Regards,

Himanshu

4 REPLIES 4
Read only

sharadendu_agrawal
Active Participant
0 Likes
585

Assign the value of the string to a variable with the required length and then u can get the required digits out from the variable into an another varibale.

Reward if helpful.

Cheers...!!!

Sharadendu

Read only

Former Member
0 Likes
586

Hi Vamsi,

U can use the following:

data : str1 type string value '123145-12300',

len type i,

off type i,

str2 type string.

len = strlen(str1).

off = len - 5.

str2 = str1+off(5).

this will populate str2 with 12300.

Regards,

Himanshu

Read only

Former Member
0 Likes
585

Here is a smapl code which works perfectly.

data: l_result type string.

field-symbols <fg1>.

l_result = '123145-12300'.

assign l_result to <fg1>.

l_result = <fg1>+5(5).

write:/ l_result.

Hope this helps.

ashish

Read only

Former Member
0 Likes
585

Hi,

You can use SPLIT to get the values as below,

SPLIT <field_text> AT '-' INTO var1 var2.

now your VAR2 contains last 5 digits