cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Element calculated field as selection field in RAP

former_member721373
Participant

Hi Everyone,

Is it possible to make the virtual element calculated field available as a Selection Field in UI as well?

The UI.SELECTIONFIELD doesn’t work on virtual element field.

Can anyone help me know if it’s possible and how?

Regards,

Ehtram

Accepted Solutions (0)

Answers (2)

Answers (2)

Marian_Zeis
Active Contributor

Have a look in the documentation:

https://help.sap.com/docs/ABAP_PLATFORM_NEW/fc4c71aa50014fd1b43721701471913d/df0ef4aac2d34fdd948b8a8...

define view entity CDSProjView
  as projection on CDSEntity
{
  key      elem_1          as Element1,

           [@EndUserText.label: 'Element Label']
           [@EndUserText.quickInfo: 'Quick Information']@ObjectModel.virtualElementCalculatedBy: 'ABAP:ABAPClass'
           @ObjectModel.filter.transformedBy: 'ABAP:ABAPClass'
           @ObjectModel.sort.transformedBy: 'ABAP:ABAPClass'
  virtual  ElemName : {DataElement | ABAPType } ,
...
}
former_member721373
Participant
0 Kudos

Hi marianzeis

I am actually looking to use virtual element fields selection fields whereas in the example provided in documentation, we apply filter on the cds view field. After checking similar questions on the forum, I guess it’s not yet possible to use transient field as a selection field. Let me know if i am wrong 😀

Marian_Zeis
Active Contributor
0 Kudos

Hi eihtu ,

thats strange because i was using this approach just this week.
It´s a little bit different use case, but i was using this blog and was using it as selection field:

https://blogs.sap.com/2020/01/16/filtering-on-association-property-in-fiori-element-app-via-abap-cds...

Föß
Active Participant
0 Kudos

Hi,

I wanted to use it in a 2021 system, somehow doesn't seem to work. (Dumps, Exceptions) - Then I checked the documentation again (for 2021), and there is no longer any mention of filter and sort.

Are your sure that it works in a S/4 2021 as well?

Regards, Johann

deepak_pandey
Advisor
Advisor
0 Kudos

Hi eihtu,

Following annotation is enough to display a Virtual Element as a Selection Field in UI:

@ObjectModel.filter.enabled: true

However, to write the logic to implement the Filter/Selection on the Virtual Element, you need following additional annotation:

@ObjectModel.filter.transformedBy: 'ABAP:<class_name>'

The <class_name> must have the Interface Method 'IF_SADL_EXIT_FILTER_TRANSFORM~MAP_ATOM' implemented.

Do Note: You cannot filter the Virtual Element values though. Using the Virtual Element filter/selection input, you can apply filter on other persisted fields only.

Filtering the Virtual Element values will give you a dump with the following error:

'Element <virtual_element> is calculated in ABAP and must not be used for DB query'