通过CDS视图添加信号灯,在Fiori前端显示状态图标,效果如下
语义图标颜色
要实现图标,需要把目标字段映射到UI.Criticality
完整code:
@AbapCatalog.sqlViewName: 'ZTEST_SPFLI'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Flight Information'
@UI.headerInfo: {typeName: 'Flight', typeNamePlural: 'Flights',
title: { value: 'carrname'}, description: { value: 'connid' } }
@OData.publish: true
define view Z_TEST_SPFLI
as select from spfli
association [1..1] to scarr as _scarr on $projection.carrid = _scarr.carrid
{
//spfli
@UI: {
lineItem: [{ position: 10, label: 'Carrier Name'}],
identification: [{position: 10, label: 'Carrier Name'}]
}
key carrid,
@UI: {
lineItem: [{ position: 20, label: 'Connection'}],
identification: [{position: 20, label: 'Connection'}]
}
key connid,
_scarr.carrname as carrname,
@UI: {
lineItem: [{ position: 30, label: 'Strat Country'}],
fieldGroup: [{ qualifier: 'Coun', position: 10, label: 'Strat Country' }]
}
countryfr,
@UI: {
lineItem: [{ position: 40, label: 'Arriving Country'}],
fieldGroup: [{ qualifier: 'Coun', position: 20, label: 'Arriving Country' }]
}
countryto,
@UI: {
lineItem: [{ position: 50, label: 'Start City'}],
fieldGroup: [{ qualifier: 'City', position: 10 }]
}
cityfrom,
@UI: {
lineItem: [{ position: 60, label: 'Arriving City'}],
fieldGroup: [{ qualifier: 'City', position: 20 }]
}
cityto,
@UI: {
lineItem: [{ position: 70, label: 'Start Airport'}],
fieldGroup: [{ qualifier: 'Airp', position: 10 }]
}
airpfrom,
@UI: {
lineItem: [{ position: 80, label: 'Arriving Airport'}],
fieldGroup: [{ qualifier: 'Airp', position: 20 }]
}
airpto,
@UI: {
fieldGroup: [{ qualifier: 'Time', position: 10 }]
}
deptime,
@UI: {
fieldGroup: [{ qualifier: 'Time', position: 20 }]
}
arrtime,
//position: 90,,
//fieldGroup: [{ qualifier: 'Xinfo', position: 10 }]
@UI: {
lineItem: [{ label: 'Flight Type', criticality: 'Criticality' }]
}
fltype,
case fltype
when ' ' then 3
when 'X' then 1
else 0
end as Criticality
}