Ansicht
Dokumentation

ABENCDS_CALCULATED_QUANTITY - CDS CALCULATED QUANTITY

ABENCDS_CALCULATED_QUANTITY - CDS CALCULATED QUANTITY

CL_GUI_FRONTEND_SERVICES - Frontend Services   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

- Calculated Quantity with Calculated Unit

A CDS calculated quantity is a component of a CDS view entity or of a CDS projection view in ABAP CDS used to store a quantity in a specific unit. A calculated quantity is always the result type of a calculation using ABAP CDS amount fields and/or ABAP CDS quantity fields. The DDIC data type of a calculated quantity is DECFLOAT34. A calculated quantity must be linked with a ABAP CDS calculated unit using the annotation @Semantics.quantity.unitOfMeasure: 'calculatedUnit'. A calculated unit is a component of the same CDS view entity of data type CHAR that specifies a self-defined unit which is not contained in any list of pre-defined values. The DDIC data element DD_CDS_CALCULATED_UNIT and DDIC domain DD_CDS_CALCULATED_UNIT can be used to type a calculated unit, but this is not mandatory.

In CDS view entities, the following functions are available for amount and quantity fields:

  • CURR_TO_DECFLOAT_AMOUNT converts an amount field of data type CURR to data type DECFLOAT34, including shifting. The result remains an amount.

Calculated quantities can be the result type of the following expressions in CDS view entities:

Moreover, special rules apply in the following operand positions in CDS view entities:

Notes

  • Reference annotations to currency or unit of measurement keys are propagated in CDS entities selecting from DDIC database tables or other CDS entities. It is possible, but not mandatory, to redefine them.
  • Currently, CDS calculated quantities are only available in CDS view entities and in CDS projection views. They are not supported in any other CDS entity.
  • If a field is a calculated quantity, this characteristic is inherited when a view entity selects from another view entity.
  • A calculated unit can be used as reference only once in a view. If a view contains several calculated quantity fields, each field needs a different calculated unit.

Example

In the following CDS view entity, the field rent_per_size divides the amount of the rent for an apartment by the apartment size. The result is the cost per square meter. The calculated unit is EUR/MTK, MTK being the unit ID for square meter.

The program DEMO_CDS_CALCULATED_QUANTITY accesses the view, inserts values into the underlying database table, and displays the result.






BAL Application Log Documentation   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 5396 Date: 20240511 Time: 192424     sap01-206 ( 57 ms )