HI All,
I Have a requirement where I have to take to omit the last 2 characters from an Input string.
eg Input string = BO1H1R5_I
output string = BO1H1R5
P.S. - I have seen the docs and there is an option of using Left string function but I can’t use this for my requirement as my input string size differ, only constant is the last 2 characters which I want to remove.
Thanks in Advance!
@ankurul What if you used the length() function and then use that with the left() function
input string = BO1H1R5_I
output string = BO1H1R5
length(“BO1H1R5_I”) = 9
then take the 9 and subtract 2 = 7
left(“BO1H1R5_I”,7 ) = BO1H1R5
1 Like
Hi Jon,
Thanks for the reply but this would not have worked in my case as I told the input string is of variable length and when you are using Left function here and trimming first 7 characters it would solve only for this example but would not work for all input strings.
Nevertheless I was able to resolve this using
substr(,0,length()-2)
I am now experiencing a different issue which is as follows:
- How can we use like operator with maxaccum
MaxAccum @searchpar;
fg_to_sales2 = select t from fgs2:s - () - SalesOrder:t where t.Year == yr and t.CountryCode == country_code
ACCUM t.@searchpar += “%” + substr(s.GlobalMaterialNumber,0,length(s.GlobalMaterialNumber)-2) + “%”
POST-ACCUM @@fgsales += t.@searchpar
LIMIT 100;
fgmat= select s from fg_to_sales2:t -()- Materials:s where s.GlobalMaterialNumber LIKE t.@searchpar;
for this I am getting error:
“pattern in like operator can only be literal string or parameter”