1.CDS视图ZI_FI_PROFIT
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: '财务运营指标'
@Metadata.ignorePropagatedAnnotations: true
define view entity ZI_FI_PROFIT
as select from zfit0006
association [1..1] to t001 as _Company on $projection.bukrs = _Company.bukrs
{
key bukrs,
key gjahr,
key monat,
key period_type,
cast( 'CNY' as abap.cuky ) as Currency,
_Company.butxt as bukrs_text,
cast( income as abap.dec(15,2) ) as income,
cast( income_year as abap.dec(15,2) ) as income_year,
cast( cost as abap.dec(15,2) ) as cost,
cast( cost_year as abap.dec(15,2) ) as cost_year,
cast( gross as abap.dec(15,2) ) as gross,
gross_rate,
cast( qjfy as abap.dec(15,2) ) as qjfy,
qjfy_rate,
cast( net as abap.dec(15,2) ) as net,
cast( net_year as abap.dec(15,2) ) as net_year,
net_rate,
net_zc_rate,
zcfz_rate,
current_ratio,
quick_ratio,
artr,
ch_rate,
artr_d,
ch_rate_d
}
2.CDS消费视图ZC_FI_PROFIT_M
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: '月度运营指标'
@Analytics.dataCategory: #CUBE
@Metadata.ignorePropagatedAnnotations: true
@UI.presentationVariant: [{
sortOrder: [
{ by: 'bukrs', direction: #ASC }, // 按照公司代码正序 (Ascending)
{ by: 'gjahr', direction: #ASC }, // 按照会计年度正序 (Ascending)
{ by: 'monat', direction: #ASC } // 按照月正序 (Ascending)
]
}]
@UI.chart: [{
qualifier: 'GrossRateMicroChart', // 给这个小图起个唯一的全剧名字
chartType: #DONUT,
measures: ['gross_rate'], // 图表绑定哪个字段
measureAttributes: [{
measure: 'gross_rate',
role: #AXIS_1,
asDataPoint: true //
}]
},
{
qualifier: 'QjfyRateMicroChart',
chartType: #DONUT,
measures: ['qjfy_rate'],
measureAttributes: [{
measure: 'qjfy_rate',
role: #AXIS_1,
asDataPoint: true
}]
}]
define view entity ZC_FI_PROFIT_M
as select from ZI_FI_PROFIT
{
@EndUserText.label: '公司代码'
@UI.lineItem: [{ position: 10 }]
@UI.selectionField: [{ position: 10 }]
@Consumption.valueHelpDefinition: [{
entity: {
name: 'ZCDS_BUKRS', // 你的现成视图名
element: 'bukrs'
}
}]
key bukrs,
@EndUserText.label: '会计年度'
@UI.lineItem: [{ position: 20 }]
@UI.selectionField: [{ position: 20 }]
key gjahr,
@EndUserText.label: '月'
@UI.lineItem: [{ position: 30 }]
@UI.selectionField: [{ position: 30 }]
key monat,
@UI.hidden: true
key period_type,
@UI.hidden: true
cast( '%' as abap.unit ) as rate_unit,
@EndUserText.label: '公司名称'
@UI.lineItem: [{ position: 20 }]
bukrs_text,
Currency,
@EndUserText.label: '收入'
@UI.lineItem: [{ position: 40 }]
income,
@EndUserText.label: '成本'
@UI.lineItem: [{ position: 50 }]
cost,
// @EndUserText.label: '毛利率'
// @Semantics.quantity.unitOfMeasure: 'rate_unit'
@UI.lineItem: [{
position: 60,
type: #AS_CHART,
valueQualifier: 'GrossRateMicroChart',
label: '毛利率'
}]
@UI.dataPoint: {
title: '毛利率',
targetValue: 100 // 告诉环形图满分是 100%
}
cast( gross_rate * 100 as abap.dec(23,2 ) ) as gross_rate,
@EndUserText.label: '期间费用'
@UI.lineItem: [{ position: 70 }]
qjfy,
// @EndUserText.label: '期间费用率'
// @Semantics.quantity.unitOfMeasure: 'rate_unit'
@UI.lineItem: [{ position: 80,
type: #AS_CHART,
valueQualifier: 'QjfyRateMicroChart',
label: '期间费用率' }]
@UI.dataPoint: {
title: '期间费用率',
targetValue: 100
}
cast( qjfy_rate * 100 as abap.dec( 23, 2 ) ) as qjfy_rate,
@EndUserText.label: '净利润'
@UI.lineItem: [{ position: 90 }]
net,
@EndUserText.label: '净利润率'
@Semantics.quantity.unitOfMeasure: 'rate_unit'
@UI.lineItem: [{ position: 100 }]
cast( net_rate * 100 as abap.dec( 23, 2 ) ) as net_rate,
@EndUserText.label: '净资产收益率'
@Semantics.quantity.unitOfMeasure: 'rate_unit'
@UI.lineItem: [{ position: 110 }]
cast( net_zc_rate * 100 as abap.dec( 23, 2 ) ) as net_zc_rate,
@EndUserText.label: '资产负债率'
@Semantics.quantity.unitOfMeasure: 'rate_unit'
@UI.lineItem: [{ position: 120 }]
cast( zcfz_rate * 100 as abap.dec( 23, 2 ) ) as zcfz_rate,
@EndUserText.label: '流动比例'
@UI.lineItem: [{ position: 130 }]
current_ratio,
@EndUserText.label: '速冻比率'
@UI.lineItem: [{ position: 140 }]
quick_ratio,
@EndUserText.label: '应收账款周转率'
@UI.lineItem: [{ position: 150 }]
artr,
@EndUserText.label: '存货周转率'
@UI.lineItem: [{ position: 160 }]
ch_rate,
@EndUserText.label: '应收账款周转天数'
@UI.lineItem: [{ position: 170 }]
artr_d,
@EndUserText.label: '存货周转天数'
@UI.lineItem: [{ position: 180 }]
ch_rate_d
}
where
period_type = 'M'
3.Service Definition
@EndUserText.label: '月度运营指标服务定义'
define service ZUI_FI_PROFIT_M {
expose ZC_FI_PROFIT_M as MonthlyProfit;
}
4.Service Binding

5.op版本记得发布服务组
激活OData V4的服务
事务码:/IWFND/V4_ADMIN

右键传输


6.预览效果
带Micro Chart

