问题
I have a CDS view for notifications header with an association to their status
define view ZNOTIF as select from qmel as notif
association [0..*] to ZNOTIF_STATUS as _status on _status.object_num = notif.objnr
{
key notif.qmnum as notif_id,
notif.objnr as object_num,
notif.qmart as type,
notif.qmtxt as description,
_status
}
Now I would like to consume this CDS in ABAP selecting all the notifications with an specific status (and without incrementing cardinality if possible).
Something like this, but of course this has a syntax error:
SELECT notif_id,
type,
description
FROM ZNOTIF
INTO TABLE @DATA(notifs)
WHERE \_status-status_id = 'STATUS_FILTER_VALUE'. "Syntax error
Can I do that somehow?
回答1:
SELECT DISTINCT notif_id,
type,
description
FROM ZNOTIF
WHERE \_status[ (*) ]-status_id = 'STATUS_FILTER_VALUE'
INTO TABLE @DATA(notifs).
来源:https://stackoverflow.com/questions/60996902/how-to-consume-a-cds-from-abap-sql-using-an-association-value-in-the-where-condi