5 Replies Latest reply: Jun 13, 2012 4:12 PM by Ravindra Channe RSS

Expression in Calculated Attributes and "Double" in Creating Table

Jans Sircar
Currently Being Moderated

Hi,

 

Please help me to understand in details why we are using Expression like this:

 

Expression: midstr(string("ERDAT"),strlen(string("ERDAT"))-9,4)

I want to learn the detailed of ths Sysntax so that I can use it in different table for creating Calculated Attribute.

My Second question:

In SQL if I write in creating Table for a field amount with syntax as

SALES_AMOUNT Decimal double

SALES_AMOUNT Decimal (2)

What is the difference between them.

Thanks,

Jans

  • Re: Expression in Calculated Attributes and "Double" in Creating Table
    Anooj Behanan
    Currently Being Moderated

    Hi Jans,

     

    midstr() according to the SQL script guide => return a part of the string starting at arg2, arg3 bytes long. arg2 is counted from 1 (not 0).

     

    So in your e.g.. it returns just the "Year" part from your date.

     

     

    Your create table statement syntax seems to be wrong. Double data type is basically your double-precision floating point number that can store a much bigger value range.

     

    Thanks,

    Anooj

  • Re: Expression in Calculated Attributes and "Double" in Creating Table
    Ravindra Channe
    Currently Being Moderated

    Hi Jans,

     

    Let me try to answer the questions:

     

    Use of expression "midstr(string("ERDAT"),strlen(string("ERDAT"))-9,4)" is to derive the YEAR for the date. It will convert the value of the Movement date to string and then using string manipulation functions like midstr and strlen it will compute the values as follows:

     

    1) strlen(string(date) -9 = will return the (length of data value) - 9

    2) midstr (<string value>, start position, no of characters) will end up selecting the first 4 characters for the string value.

     

    Hence this expression should return the first 4 characters from the ERDAT value which is the YEAR.

     

    Coming to the second question:

     

    I am not sure if there is DECIMAL DOULBE option. There is Decimal (precision, scale) and Double.

     

    With Decimal(2) there column can contain only 2 digit values, where as double column can contain much larger value.

     

    For the details on DECIMAL and DOUBLE, I'd suggest you refer to the HANA SQL Guide at http://help.sap.com/hana/hana_sql_en.pdf

     

    Hope this helps

     

    Regards,

    Ravi