如何使用 WHERE 条件中的关联值从 ABAP SQL 使用 CDS?
How to consume a CDS from ABAP SQL using an association value in the WHERE condition?
我有通知的 CDS 视图 header 与其状态相关联
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
}
现在我想在 ABAP 中使用此 CDS,选择所有具有特定状态的通知(如果可能,不增加基数)。
类似这样的东西,但这当然有语法错误:
SELECT notif_id,
type,
description
FROM ZNOTIF
INTO TABLE @DATA(notifs)
WHERE \_status-status_id = 'STATUS_FILTER_VALUE'. "Syntax error
我可以这样做吗?
SELECT DISTINCT notif_id,
type,
description
FROM ZNOTIF
WHERE \_status[ (*) ]-status_id = 'STATUS_FILTER_VALUE'
INTO TABLE @DATA(notifs).
我有通知的 CDS 视图 header 与其状态相关联
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
}
现在我想在 ABAP 中使用此 CDS,选择所有具有特定状态的通知(如果可能,不增加基数)。
类似这样的东西,但这当然有语法错误:
SELECT notif_id,
type,
description
FROM ZNOTIF
INTO TABLE @DATA(notifs)
WHERE \_status-status_id = 'STATUS_FILTER_VALUE'. "Syntax error
我可以这样做吗?
SELECT DISTINCT notif_id,
type,
description
FROM ZNOTIF
WHERE \_status[ (*) ]-status_id = 'STATUS_FILTER_VALUE'
INTO TABLE @DATA(notifs).