cancel
Showing results for 
Search instead for 
Did you mean: 

HANA Calculation View: charpos function

roland_bouman
Contributor
0 Kudos

Hi! Can somebody provide me with a practical example of the charpos() function in the context of Column Engine calculated attributes in HANA Calculation views?

To be sure, I know where it is documented, I'm just trying to understand the use case.

https://help.sap.com/viewer/e8e6c8142e60469bb401de5fdb6f7c00/2.0.03/en-US/f5a9ca3718354a499a98ba61ae...

View Entire Topic
Vitaliy-R
Developer Advocate
Developer Advocate

Hi Roland. I read it as a shorter version of the midstr(string, int, 1) selecting only a single character from the string 🙂

As SQL engine is taking over execution of calc views I would rather pay attention to functions available in https://help.sap.com/viewer/e8e6c8142e60469bb401de5fdb6f7c00/2.0.05/en-US/e77fbb1c28af414dadaa8a056f...

Regards.

roland_bouman
Contributor
0 Kudos

vitaliy.rudnytskiy

thanks for chiming in, much appreciated.

> I read it as a shorter version of the midstr(string, int, 1) selecting only a single character from the string 🙂

Yeah I can see why you'd think that, based on the name. I read it too as "char at pos". But it's not that at all. I included a link to its documentation and that reads:

return the position of the nth character in a string (n starting with 1). The string is interpreted as UTF-8 as it is in the preceding chars() function.

I appreciate that you're pointing out that I can use SQL functions but the point here is that I am in a migration project and I want to be prepared to migrate any column engine expression. Hence I'd like to better understand practical examples where people use this function.

(My thinking now is that charpos deals with certain details around single/multibyte character sets which plague other column engine string functions too. IMO these details should never be a concern to use, but unfortunately they are)