如何使用 WHERE 条件中的关联值从 ABAP SQL 使用 CDS? [英] How to consume a CDS from ABAP SQL using an association value in the WHERE condition?
本文介绍了如何使用 WHERE 条件中的关联值从 ABAP SQL 使用 CDS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个通知标题的 CDS 视图,并与其状态关联
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
}
现在我想在 ABAP 中使用这个 CDS,选择具有特定状态的所有通知(如果可能,不增加基数).
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?
推荐答案
SELECT DISTINCT notif_id,
type,
description
FROM ZNOTIF
WHERE \_status[ (*) ]-status_id = 'STATUS_FILTER_VALUE'
INTO TABLE @DATA(notifs).
这篇关于如何使用 WHERE 条件中的关联值从 ABAP SQL 使用 CDS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文