负责人和参考期间

ABAP RESTful 应用程序编程模型 › 开发 › 开发 UI 特定 › 定义元数据驱动的 UI 的 CDS 注释 › 元数据驱动 UI 的更多选项 › 数据点 › 负责人和参考期间

获取有关如何使用数据点在 SAP Fiori UI 上显示对负责人和参考期间的参考的信息。

您可以将以下属性添加到 UI 注释 @UI.dataPoint:

  • referencePeriod

  • responsibleName

您可以直接在 UI 注释中定义这两个属性,也可以在另一个元素中定义这两个属性,并从 UI 注释中引用此元素。

示例

在以下示例中,数据点具有静态参考期间和静态负责人。总金额值的格式设置为 valueFormat 属性。因此,该值使用因子 1000 进行缩放,并以一位小数显示,即值 34500 欧元将显示为 34.5 千欧元。

示例代码

...
define view ZExample_SalesOrdersByCustomer as select from ... as so {
  key so.buyer_guid as BuyerGuid,

  @Semantics.currencyCode: true
  so.currency_code as CurrencyCode,

  @UI.dataPoint: {
    title: 'Gross Amount',
    description: 'Gross Amount per Customer',
    longDescription: 'The gross amount per customer ...',
    valueFormat: {
      scaleFactor: 1000,
      numberOfFractionalDigits: 1
    },
    referencePeriod: { description: '2015 Q3' },
    responsibleName: 'John Doe'
  }
  @Semantics.amount.currencyCode: 'CurrencyCode'
  so.actual_amount as ActualAmount
}

示例

在以下示例中,使用由以下参数提供的动态参考期间:

  • start

  • end

必须先在元素列表中使用这些参数的别名,然后才能在 @UI.dataPoint 注释中使用。负责属性必须引用对一关联。此关联的目标实体应包含负责人的联系人数据。

展开以下代码示例以查看源代码

示例代码

...
define view ZExample_SalesOrdersByCust
with parameters p_StartDate : abap.dats,
                p_EndDate   : abap.dats
as select from ... as so
association [0..1] to Employees as _PersonResponsible
  on _PersonResponsible.EmployeeId = $projection.PersonResponsible
{
  ...

  $parameters.p_StartDate as StartDate,	-- Alias is required for annotation
  $parameters.p_EndDate as EndDate,		-- Alias is required for annotation
  so.person_responsible as PersonResponsible,

  @Semantics.currencyCode: true
  so.currency_code as CurrencyCode,

  @UI.dataPoint: {
    title: 'Gross Amount',
    referencePeriod: {
      start: 'StartDate',				-- Reference to element
      end: 'EndDate'				-- Reference to element
    },
    responsible: '_PersonResponsible'		-- Reference to association
  }
  @Semantics.amount.currencyCode: 'CurrencyCode'
  @DefaultAggregation: #SUM
  so.actual_amount as ActualAmount,

  _PersonResponsible
}
where so.validity_date >= $parameters.p_StartDate
and   so.validity_date <= $parameters.p_EndDate

示例代码

有关元素清单的定义,请参阅下面链接的 术语表 部分。