ITPub博客

首页 > 应用开发 > IT综合 > 如何用ABAP读取CDS view association的数据

如何用ABAP读取CDS view association的数据

原创 IT综合 作者:i042416 时间:2020-02-09 08:50:33 0 删除 编辑

AG3, view name Zorder_Sys_Status.

This view has an association named _statushelp:

# Requirement

I would like to read the guid from host view Zorder_Sys_Status together with its associated data via association _statushelp.

(1) Since there is no existing data type which holds both host view field and associated view fields, you have to create one on your own:

(2) Use the following syntax in ABAP code:

```abap

DATA: lt_data TYPE tt_Data.

SELECT

guid,

\_STATUSHELP-STATUS_KEY AS STATUS_KEY ,

\_STATUSHELP-STATUS_TEXT AS STATUS_TEXT

FROM

ZORDER_SYS_STATUS

WHERE

ZORDER_SYS_STATUS~GUID = 'FA163E8EAB031EE6A99F824537D112A4' AND ZORDER_SYS_STATUS~STAT = 'I1002' AND \_STATUSHELP-STATUS_KEY IS NOT NULL

INTO TABLE @lt_data.

```

By the way, when the association defined in CDS view is consumed via OPEN SQL, it will be converted to LEFT OUTER JOIN, as could be observed in SQL trace:

In ST05, select your trace record, and click this button in toolbar:


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24475491/viewspace-2674851/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
测试

注册时间:2018-01-20

  • 博文量
    3822
  • 访问量
    1982159