在前一篇文章如何给 SAP Fiori Elements 应用的字段添加 value help,我们已经通过注解的方式,给 Fiori Elements 应用的 selection field,加上了 value help 功能。

本文通过使用文本关联(Text Association),将 Agency Name 添加到 ID,我们将使代理字段更具可读性。

CDS association 只是 join 的规范,始终在语法中的相同位置。

关联的主要优点是重用:一旦指定了一次关联,就可以方便地将多个关联串连到一个路径中。

来进行实际的操作。

添加下图第9行和第13行 text association 相关的代码:

一步步学习 SAP CDS view Text Association 在 SAP Fiori Elements 中的应用

@AbapCatalog.sqlViewName: 'ZCTRAVELJERRY'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Consumption view from /DMO/I_TRAVEL_U'
@Metadata.allowExtensions: true
@Search.searchable: true
define view Z_C_TRAVEL_DATA_JERRY as select from /DMO/I_Travel_U 
association [1..1] to /DMO/I_Agency as _Agency on $projection.AgencyID = _Agency.AgencyID
{       
    key TravelID,

    @ObjectModel.text.association: '_Agency'
    AgencyID,
    CustomerID,
    BeginDate,
    EndDate,
    BookingFee,
    TotalPrice,
    CurrencyCode,
    @Search.defaultSearchElement: true
    @Search.fuzzinessThreshold: 0.90
    Memo,
    Status,
    LastChangedAt,
    /* Associations */
    _Agency,
    _Booking,
    _Currency,
    _Customer
}

添加 text association 之前的 Fiori Elements 应用,Agency ID 和 Agency Name 是分成两列单独显示的:
一步步学习 SAP CDS view Text Association 在 SAP Fiori Elements 中的应用

使用 text association 之后的效果:Agency ID 和 Agency Name 合并成一列显示了:

一步步学习 SAP CDS view Text Association 在 SAP Fiori Elements 中的应用

更多Jerry的原创文章,尽在:"汪子熙":
一步步学习 SAP CDS view Text Association 在 SAP Fiori Elements 中的应用

相关文章:

  • 2021-09-19
  • 2021-04-26
  • 2021-06-03
  • 2021-07-19
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-25
  • 2021-07-30
  • 2021-12-13
  • 2022-12-23
  • 2021-07-29
相关资源
相似解决方案