‎2007 Oct 17 5:25 AM
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
‎2007 Oct 17 5:29 AM
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
‎2007 Oct 17 5:28 AM
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
‎2007 Oct 17 5:29 AM
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
‎2007 Oct 17 5:29 AM
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
‎2007 Oct 17 5:29 AM
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