Skip to Content
1

CAST doesn't work for DF34_DEC type

Nov 09, 2016 at 04:46 AM

240

avatar image

Hello,

I'm trying to cast a DF34_DEC type to CHAR or DECIMAL as the values appear in scientific notation for initial value (0E -12), but run into compile time errors.

Is this not supported yet? Please let me know if there is an alternate/better way.

Options used - CAST & fltp_to_dec()

Thanks!

Regards,

Shakul.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Horst Keller
Nov 09, 2016 at 04:08 PM
1
Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hello Horst,

strange, I'm not able to view your blog. Seems like it gets blocked by our SAP proxy here. Is it HTTPS or HTTP that you are using? Could you please re-post the link?

Regards,

Shakul.

0

Hello Horst,

was finally able to get to your blog via a convoluted way through your posts ;)

Regards,

Shakul.

0

I've fixed the link.

1

Thanks Matthew, I'm able to access it directly now.

0
Sandra Rossi Nov 09, 2016 at 09:00 AM
0

What is the use case of casting a decfloat34 to characters? But do you really mean ASSIGN df34 TO <c> CASTING? Or are you talking about explicit type conversion df34 to characters?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hello Sandra,

like I have mentioned, the initial values for DF34_DEC come up as 0E -12 which is not user friendly on the UI. I have even tried to cast using the function FLTP_TO_DEC( ) to cast this to DECIMAL, but that doesn't seem to work either.

By casting I mean, using the keyword CAST in ABAP CDS or the CDS built-in function FLTP_TO_DEC( ).

Regards,

Shakul.

1
Armin Junge Nov 09, 2016 at 10:23 AM
0

Do the type have a conversion routine? If yes, can you use it to convert it to internal format? Afterwards it should be easy to convert the value to a decimal or string (characters), if still needed.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hello Armin,

I don't have a conversion routine on the data element, so when I use this as an underlying data type in my CDS View, the initial entries come up in scientific notation i.e. 0E -12.

Regards,

Shakul.

0
Shakul Jugran
Nov 17, 2016 at 06:14 AM
0

I pushed both casting operations through TO_DECIMAL( ) and SUM into a table function(AMDP) and it worked. Just in case someone wants to know a work-around for DECFLOAT types.

Regards,

Shakul.

Share
10 |10000 characters needed characters left characters exceeded