cancel
Showing results for 
Search instead for 
Did you mean: 

Error extending draft enabled Standard Fiori Elements CDS View using Virtual Element

jensch
Explorer
694

Hi all,

I am trying to extend a standard Fiori App by adding another selection field. The field is in an association with [0..*] cardinality thats why I am trying to add the filter using a virtual element just as described in those two blogs:
https://startup.lwmeta.com/2021/08/24/fiori-elements-standard-app-extension-using-virtual-elements-m...
https://blogs.sap.com/2020/01/16/filtering-on-association-property-in-fiori-element-app-via-abap-cds...

But I am getting the following error:

Draft entity &1: Virtual element &2 has no calculation exit

I tried to add the virtual element as follows

extend view /oaa/C_Source_Prop with ZXXX {

    @ObjectModel.readOnly: true  
    @UI.selectionField: [{ position: 80 }] 
    @ObjectModel.filter.transformedBy: 'ABAP:ZCL_SOURCE_PROP'
    cast( '' as /oaa/net_descr ) as NetworkDescription2

} 

The transformation class is also implemented.

CLASS zcl_source_prop DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES if_sadl_exit_filter_transform .
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zcl_euoaa_source_prop IMPLEMENTATION.
  METHOD if_sadl_exit_filter_transform~map_atom.
    DATA(l_description) = cl_sadl_cond_prov_factory_pub=>create_simple_cond_factory( )->element( '_NETWORKSOURCE.DESCRIPTION' ).
    ro_condition = l_description->equals( iv_value ).
  ENDMETHOD.
ENDCLASS.

I am not familiar with draft entities, but I saw that the consumption view is draft enabled. Are there any problems regarding virtual elements and draft enabled entities? I couldn't find any information on this problem.

Accepted Solutions (0)

Answers (1)

Answers (1)

michal_k_fadrowski
Discoverer

You can fix this issue by adding an annotation to NetworkDescription2

@ObjectModel.virtualElementCalculatedBy: 'ABAP:/ZCL_SOURCE_PROP'

Now your class ZCL_SOURCE_PROP needs to implement the interface if_sadl_exit_calc_element_read.

Then add methods 'if_sadl_exit_calc_element_read~calculate' and 'if_sadl_exit_calc_element_read~get_calculation_info'. You don't need to provide any logic to these methods. This should already fix your error.