Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

Character to Quantity in CDS views

0 Kudos

Hello Gurus,

Am working for one of the ABAP CDS view to display the report in FIORI APP. I have created a Consumption view with annotations. I have used the Sales related tables and CDHDR, CDPOS tables.

There is a requirement for one column, I need to divide the delivery quantity from VBEP with Old Value from CDPOS table. Here CDPOS-VALUE_OLD is character field.

When I try to write the logic in CDS view as DIVISION( vbep.dlvqty_su,CDPOS-VALUE_OLD,2) * 100. Due to VALUE_OLD is a character field, system throwing an error like "Function DIVISION: parameter at position 2 has incorrect data type CHAR". I tried to use CAST operation to convert the char to QUAN then that time am getting error like "CAST OLD_VALUE of type CHAR to type QUAN is not possible".

Can you please help me how to convert CDPOS-VALUE_OLD value to Quantity so that I can write the DIVISION operator in Consumption view.

Thanks and Regards,

Muralikrishna Peravali.


Active Contributor
0 Kudos

AFAIK you cannot convert CHAR to QUAN, but you could convert CHAR to NUMC

Reference : ABAP CDS - cast_expr and conversion rule Source types CHAR and SSTRING

0 Kudos


I had a requirement to convert Char to currency. As direct casting of char to currency is not possible, we need to cast char to numc first and then to currency. So, I converted Char to Currency , by concatenating '.00' to char value , then casting it to numc , an again casting it to Currency.

cast( cast(concat(amountchar, '.00') as abap.numc(30) ) as wrbtr_z) as Amountcurrency

muralikrishna.peravali2 Hope the same can be applied to quantity conversion.