cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Display custom logic from abap program into cds view

YABAPER
Explorer
0 Kudos
1,011

Hi everyone

I am working on a cds view which displays all the selected fields via a fiori elements preview. I have an abap program that calculates some custom fields as such:

REPORT z_outstanding_days.
DATA: lt_swwwihead TYPE TABLE OF swwwihead, ls_swwwihead TYPE swwwihead, lv_days_outstanding TYPE i, lv_current_date TYPE d. * Get the current date lv_current_date = sy-datum. * Select data from SWWWIHEAD table SELECT * FROM swwwihead INTO TABLE lt_swwwihead WHERE wi_stat = 'READY'. * Loop through the selected work items LOOP AT lt_swwwihead INTO ls_swwwihead. * Calculate the number of days outstanding lv_days_outstanding = lv_current_date - ls_swwwihead-crdate. * Print the work item ID and the number of days outstanding WRITE: / 'Work Item ID:', ls_swwwihead-wi_id, 'Days Outstanding:', lv_days_outstanding. ENDLOOP.

How can I pull the custom calculated field from the abap program into the following CDS view

@AbapCatalog.sqlViewName: 'ZV_OUTSTANDING_ITEMS'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Outstanding Work Items with Approvers'
define view ZV_OutstandingItems as select from swwwihead
  LEFT OUTER join swwuserwi on swwwihead.wi_id = swwuserwi.wi_id
{
  key swwwihead.wi_id,
  swwwihead.crdate,
  swwwihead.wi_text,
}



Accepted Solutions (0)

Answers (2)

Answers (2)

MBartsch71
Participant

Hi,

to put custom logic in a cds view you can use Custom entities for CDS. There you can specify a class which dos the data determination.

Kind Regards

Matt

YABAPER
Explorer
0 Kudos

.

junwu
SAP Champion
SAP Champion
0 Kudos
if you only have a few fields coming from abap, you won't want to use custom entity
junwu
SAP Champion
SAP Champion

google virtual element +cds

Prasenjitsbist
Participant
0 Kudos
Virtual elements are only allowed in RAP applications
junwu
SAP Champion
SAP Champion
0 Kudos
no, your information is not correct.