ABAP CDS排序
时间: 2023-11-09 07:00:15 浏览: 409
在 ABAP CDS 中,可以使用 ORDER BY 子句对结果进行排序。例如,以下代码将按照物料描述对 SFLIGHT 表进行排序:
```
@AbapCatalog.sqlViewName: 'ZV_FLIGHT'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Flight with Sorting'
define view ZV_Flight_With_Sorting as select from sflight {
key carrid,
key connid,
fldate,
price,
currency,
planetype,
seatsmax,
seatsocc,
distance,
cityfrom,
cityto,
cast(
case
when length(countryfr) = 3 then countryfr
else ' '
end as abap.char(3)
) as countryfrom,
cast(
case
when length(countryto) = 3 then countryto
else ' '
end as abap.char(3)
) as countryto,
cast(
case
when length(planetype) = 0 then ''
else planetype
end as abap.char(20)
) as type_description
} order by fldate, cityfrom, cityto, type_description;
```
在此示例中,使用 `order by` 子句将结果按照 `fldate`, `cityfrom`, `cityto`, `type_description` 列排序。
阅读全文