Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to check if field is numeric or not in calculated column

Hello,

I have created a simple attribute view in which I want to check if the KUNNR field is NUMERIC or not and print the result accordingly. There is no IS_NUMERIC function available in string functions so please help to write it with help of IF or CASE statement.

Thanks,

SHriniwas

Former Member
replied

Hello Shriniwas,

I think you can use the ltrim function in combination with the chars function to check for that.

With ltrim you can remove the numbers and characters from the left side of the string.

With chars you count the still available characters after ltrim. If the counted number is greater than 0 it is alpha-numeric, if 0 it is numeric.

Example:

if(chars(ltrim("KUNNR",'0123456789')) > 0,'is alpha-numeric','is numeric')

-> for '120000' -> counter is 0 -> numeric

-> for '12000A' -> counter is 1 -> alpha-numeric

-> for 'A20000' -> counter is 6 -> alpha-numeric

Of course you can adapt the second argument of the ltrim and if function to your needs (e.g. add '+-.' for ltrim in case you check other fields with sign and decimal separator values).

Best Regards,

Florian

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question