1. 依次创建如下CDS视图
@AbapCatalog.sqlViewName: 'ZDEMO_SCARR01_V'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'SCARR DEMO'
define view ZDEMO_SCARR01_CDS as select from scarr {
//SCARR
key scarr.carrid,
scarr.carrname as Carrname,
scarr.currcode as Currcode,
scarr.url as Url
}
@AbapCatalog.sqlViewName: 'ZDEMO_SCARR02_V'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'SCARR02'
@VDM.viewType: #TRANSACTIONAL
define view ZDEMO_SCARR02_CDS as select from ZDEMO_SCARR01_CDS{
key ZDEMO_SCARR01_CDS.carrid,
ZDEMO_SCARR01_CDS.Carrname,
ZDEMO_SCARR01_CDS.Currcode,
ZDEMO_SCARR01_CDS.Url
}
@AbapCatalog.sqlViewName: 'ZDEMO_SCARR03_V'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'SCARR03'
@OData.publish: true --enable odata
@UI:{
headerInfo: {
typeName: 'Flight',
typeNamePlural: 'Flight'
}
}
@Search.searchable: true
@VDM.viewType: #CONSUMPTION
define view ZDEMO_SCARR03_CDS as select from ZDEMO_SCARR02_CDS {
@UI: {
facet: [
{ label: 'Flight', id: 'FlightId', position: 10, type: #COLLECTION },
{ parentId: 'FlightId', type: #FIELDGROUP_REFERENCE, targetQualifier: 'FlightIdFG' }
],
// fieldgroup used for grouping all fields with same qualifier to one group
fieldGroup: [{ qualifier: 'FlightIdFG', position: 10, label: 'Flight ID' }],
// Identification used for detailed view
identification: [{ position: 10, importance: #HIGH }],
// lienitem used for position in the list view
lineItem: [{ position: 10, label: 'Flight ID' }]
}
@Consumption.filter.hidden: true
@Search.defaultSearchElement: true // default search field carrid
key ZDEMO_SCARR02_CDS.carrid,
@UI: {
fieldGroup: [{ qualifier: 'FlightIdFG', position: 20, label: 'Flight Name' }],
identification: [{ position: 20, importance: #HIGH }],
lineItem: [{ position: 20, label: 'Flight Name' }]
}
ZDEMO_SCARR02_CDS.Carrname,
@UI: {
fieldGroup: [{ qualifier: 'FlightIdFG', position: 30, label: 'Flight Currency' }],
identification: [{ position: 30, importance: #HIGH }],
lineItem: [{ position: 30, label: 'Currency' }]
}
ZDEMO_SCARR02_CDS.Currcode,
@UI: {
fieldGroup: [{ qualifier: 'FlightIdFG', position: 40, label: 'Flight URL' }],
identification: [{ position: 40, importance: #HIGH }],
lineItem: [{ position: 40, label: 'Flight URL' }]
}
ZDEMO_SCARR02_CDS.Url
}
2. /n/IWFND/MAINT_SERVICE 添加服务
3. VS code 生成视图
4. 测试效果
https://blog.csdn.net/xiefireworks/article/details/126576032