CDS view programming

Selection via join and filling two virtual columns

as select
ekpo.matnr as Material,
ekpo.werks as Plant,
ekpo.meins as UnitOfOrder,

case ekpo.pstyp
when '2' then 0
else case ekpo.retpo
when 'X' then -1 * eket.menge - eket.wemng
else eket.menge - eket.wemng
end
end as open_po_qty,

case ekpo.pstyp
when '2' then

case ekpo.retpo
when 'X' then -1 * eket.menge - eket.wemng
else eket.menge - eket.wemng
end
else 0
end as open_po_consi_qty,

ekpo.umrez,
ekpo.umren

from ekpo as ekpo
inner join eket as eket on ekpo.mandt = eket.mandt
and ekpo.ebeln = eket.ebeln
and ekpo.ebelp = eket.ebelp
inner join ekko on ekpo.mandt = ekko.mandt
and ekpo.ebeln = ekko.ebeln
where
eket.wemng < eket.menge
and ekpo.loekz = ''
and ekpo.elikz = ''
and ekpo.wepos <> ''
and ekpo.bstyp = 'F'
and ekko.bsart = 'NB'

Comments