Files
abap-llm/tasks_gen/train/G1080/faulty/m0_i_vend_state.ddls.asddls
2026-10-05 18:02:52 +02:00

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
left outer 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