abapcds

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

  • 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