'Show output values aka conversion-exit values in CDS?

I've created a CDS view, which reads some data from 2 tables. My problem is, that one of the columns has a conversion policy behind - so if I display the data with SE16n, it shows the "converted value" but within my cds view only the unconverted value is shown.

Is there an option to show converted values in CDS views?



Solution 1:[1]

Use Virtual Elements

they can be used to calculate fields that are not available in CDS.

Steps

  1. Add a placeholder field: cast( '' as abap.char(255)) AS after_conversion
  2. Add Annotation @ObjectModel.virtualElement: true to your field
  3. Add Annotation @ObjectModel.virtualElementCalculatedBy: 'ABAP:<z_class>'
  4. Create the Class Z_CLASS
  5. Use interface if_sadl_exit_calc_element_read
  6. In Method calculate you can do the conversion

Here you can see a simple example

Solution 2:[2]

No actually conversion exits are not supported in CDS. But with string conversions you can rebuild the conversion exits.

-> see Documentation

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AndrĂ¡s
Solution 2 noah