The database model consists of the table SBOOK
containing the earnings from the customer.
The operating costs are stored in table ZFLIGHT_COSTS
.
SBOOK
and ZFLIGHT_COSTS
we must use either an aggregate function for zflight_costs~costs
or must add this field to the group by-clause like in the code sample below.
SELECT c~carrid, c~connid, c~fldate, c~costs AS operating_costs, c~currency, sum( b~loccuram ) as earning
FROM zflight_costs AS c INNER JOIN sbook AS b
ON b~carrid = c~carrid AND b~connid = c~connid AND b~fldate = c~fldate
INTO TABLE @DATA(flight_profits)
GROUP BY c~carrid, c~connid, c~fldate, c~currency, c~costs.
@AbapCatalog.sqlViewName: 'zflight_ear'
@AbapCatalog.preserveKey: true
@EndUserText.label: 'Flight earnings'
define view zflight_earnings as select from sbook {
key carrid,
key connid,
key fldate,
sum( loccuram ) as earning,
loccurkey as currency
} group by carrid, connid, fldate, currency
ZFLIGHT_EARNINGS
can be joined with the table ZFLIGHT_COSTS
in an another CDS-view.
@AbapCatalog.sqlViewName: 'zflight_prof'
@AbapCatalog.preserveKey: true
@EndUserText.label: 'Flight profit'
define view zflight_profit as select from zflight_costs as c
inner join zflight_earnings as b on b.carrid = c.carrid and b.connid = c.connid
and b.fldate = c.fldate {
key c.carrid,
key c.connid,
key c.fldate,
c.costs as operating_costs,
c.currency,
b.earning
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 | |
2 |