cancel
Showing results for 
Search instead for 
Did you mean: 

CDS VIEW ENTITY - CURR / QUAN calculated field gives activation error

bharatbajaj
Active Participant
0 Kudos
615

Dear community members,

I need to create a CDS view entity with a calculated filed as CURR / QUAN to get the per unit amount.

For Example: CDS VIEW ENTITY on BSEG which should have ( DMBTR(type CURR) / MENGE(type QUAN) ) AS UNIT_PRICE

Sounds like a very simple requirement but I am facing multiple issue with this.

To start with, I get below error message:

"Data type CURR is not supported at this position, see long text"

bharatbajaj_1-1725970019610.png

then I tried with casting CURR field as DEC(23.2), but then I got below error :

"Element <XXXXX> : missing CALC-reference annotation Semantics.quantity.unitOfMeasure"

bharatbajaj_6-1725972406979.png

it was surprising to see that it prompted to user UOM reference, instead of Currency reference, but nevertheless, I tried with the UoM reference, but then again a different error :

"<XXXXX>: Reference Field MEINS has a wrong data type"

bharatbajaj_7-1725972546520.png

then I tried to CAST the MEINS as abap.char(3) to use it as reference for calculated field, but then a different error this time, and this is really annoying this it didn't allow casting a text value into CHAR.

bharatbajaj_8-1725972773634.png

I also tried to google this error message and found some conversion function but then I get different errors:

1. Using function : GET_NUMERIC_VALUE

"Element DMBTR has an invalid reference field"

bharatbajaj_2-1725970332483.png

2. using function : CURR_TO_DECFLOAT_AMOUNT 

"Element DMBTR has an invalid reference field"

bharatbajaj_3-1725970793825.png

I tried few more ways but none of them is working for me and I really wonder how can this be so challanging to achieve AMOUNT / QUANTITY in CDS VIEW ENTITY, which is a very basic arithmetic operation.

 

Same arithmetic calculation works perfectly well in ABAP code (as we have done that for decades), so now I am thinking to use Virtual elememt in CDS, but I want to achieve with the CDS approach first, without making use of ABAP layer.

 

Any tips to solve this ?

 

regards,

Bharat Bajaj

 

View Entire Topic
raymond_giuseppi
Active Contributor
0 Kudos
bharatbajaj
Active Participant
0 Kudos
Yes I did already. and I also tried some of those and you can see the issue that I still got in my original post, as well as the comment I made on Martin's Reply below.
raymond_giuseppi
Active Contributor
0 Kudos

NB: You will require the currency codes in the view: bkpf-waers and t001-waers

NB: field rfccur is related to amount fcsl, not dmbtr or wrbtr

bharatbajaj
Active Participant
0 Kudos

Hi Raymond,

The field rfccur is a currency fields which can be used as a reference for any Amount field in BSEG (type CURR) such as DMBTR, WRBTR etc.