2

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?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
toffler
  • 1,231
  • 10
  • 27
  • 1
    I guess you need to add ABAP logic to the CDS view. Did you try with a CDS Table Function? – Sandra Rossi Apr 22 '22 at 09:27
  • I tried with Eclipse ADT --> create core data service. I guess there is no way to implement ABAP logic there – toffler Apr 22 '22 at 09:49
  • I was talking about Data Definition > next > next > select "Define Table Function with Parameters" but in fact it can be only HANA SQLscript, so forget it. – Sandra Rossi Apr 22 '22 at 12:24

2 Answers2

3

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

-> see Documentation

noah
  • 33
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 22 '22 at 13:45
3

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

András
  • 1,326
  • 4
  • 16
  • 26