cancel
Showing results for 
Search instead for 
Did you mean: 

FLTP_TO_DEC conversion in CDS extension view

0 Kudos

Hi,

I am currently working on extending a standard view, which involves calculations and conversions of numbers. I noticed that I am receiving an error: "The current expression is not supported in the selection list", but I am uncertain as to why this expression would not work. Is this a limitation within CDS Extension views?

When reading through the documentation I am following the correct syntax, the only difference I can see is that this is a CDS Extension. However, I cannot find any information if this function is not available. Would you perhaps know why this expression is not available in a CDS Extension View?

Best regards,

Hendrik

Accepted Solutions (0)

Answers (1)

Answers (1)

michael_piesche
Active Contributor

Casting from FLTP to DEC is not supported, and in fact no casting from FLTP into any other data type is supported:

" A CAST expression should be platform-independent. Conversions from the type FLTP to other numeric types are not allowed because the result would be platform-dependent.

If your original values are FLTP, you will have to continue working with the FLTP types. If it was an implicit casting by a function, like DIVISION for example, you will have to use a different function/operator that supports FLTP, like the division operator '/' for example.

If your original values are not FLTP, dont cast them to FLTP and back to DEC, you will have to find another way.

Can you give more detail about the function / coding that was used that raises this error?

I know using "CAST" is not allowed, that is why I am not casting FLTP to DEC using the regular CAST. There is a function inside CDS called "FLTP_TO_DEC", which allows FLTP to be converted to DEC:

https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_conv_func_types.htm

The question is why this expression cannot be used inside CDS Extension views.

I only want to have 2 decimals in my output, I tried to convert FLTP(16,16) to FLTP(16,2), but CDS also does not allow this and wants a fixed FLTP(16,16). Casting to DEC seemed to be a solution, but it seems like this expression causes my question.

michael_piesche
Active Contributor
0 Kudos

dlw_hvh, can you post the relevant parts of the expression that you have defined? Also, did you test, that when you eliminate the FLTP_TO_DEC function, that you dont receive the error?

" In the demo the function FPLTC_TO_DEC has been defined as:
fltp_to_dec( fltp1 as abap.dec(10,3) ) as attrname

FLTP(16,16) and FLTP(16,2) is the same. You cannot control the length and 'decimals' of a floating point number, even though you can 'define' them which is simply a user interface issue of SE11. For example, when you define a floating point number (TYPE f) in ABAP coding, you cannot set these two values either. The length of an FLTP is always 16 and the available 'real' decimals are dependent on the exponent of the current value.

michael_piesche
Active Contributor

dlw_hvh, were you able to solve your problem?

Hello Michael,

I haven't been able to solve the issue. The function works fine inside a regular cds, but in an extension view it cannot be used and throws an error. We just use a simple example of the function where we convert an floating point to decimal:

 fltp_to_dec( 1.0 as abap.dec(10,0) ) as dec1_10_0

Works fine in a regular CDS, throws a syntax error in extension views.

Our solution was doing other calculations and Fiori converts the values to a more readable format. It's a workaround, but not a solution to why it doesn't work.

michael_piesche
Active Contributor
0 Kudos

dlw_hvh, based on the ABAP documentation of FLTP_TO_DEC, I currently dont see why it should only work for CDS Views but not for CDS Extension Views. I assume your CDS View with the CDS Extension works perfectly fine without the problematic statement FLTP_TO_DEC? If so, I would suggest to report an incident on support.sap.com.