26 lines
1.1 KiB
Plaintext
26 lines
1.1 KiB
Plaintext
@AccessControl.authorizationCheck: #NOT_REQUIRED
|
|
@EndUserText.label: 'Vending machine state'
|
|
define view entity {{P}}I_VEND_STATE
|
|
as select from {{p}}vmach as machine
|
|
inner join {{p}}vslot as slot on slot.machine_id = machine.machine_id
|
|
{
|
|
key machine.machine_id as machine_id,
|
|
upper( machine.location ) as location,
|
|
count( * ) as slot_count,
|
|
cast( sum( case when slot.fill_level = 0
|
|
then 1
|
|
else 0
|
|
end ) as abap.int4 ) as empty_slots,
|
|
division( sum( slot.fill_level ) * 100,
|
|
sum( slot.max_units ), 1 ) as fill_rate,
|
|
case
|
|
when sum( slot.fill_level ) <> 0 then 'EMPTY'
|
|
when division( sum( slot.fill_level ) * 100,
|
|
sum( slot.max_units ), 1 ) < 25 then 'LOW'
|
|
else 'OK'
|
|
end as status
|
|
}
|
|
group by
|
|
machine.machine_id,
|
|
machine.location
|