How to consume a CDS from ABAP SQL using an association value in the WHERE condition?

北城余情 提交于 2021-01-04 09:20:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!