gpt4 book ai didi

abap - 从 CDS 实体中选择还是从 CDS 数据库 View 中选择

转载 作者:行者123 更新时间:2023-12-01 12:24:42 25 4
gpt4 key购买 nike

在 SAP 的 ABAP CDS 中,define view语句用于创建 CDS View 。这个对象有一个 CDS 实体名称,这就是它在编辑器和包中的显示方式,但它还有一个 AbapCatalog.sqlViewName必须不同的注释。 The documentation of the define view syntax有一些信息:

Two objects are created for a CDS view (of the ABAP CDS) that is defined using DEFINE VIEW. A name must be specified for each of the two objects:

  • The name CDS_DB_VIEW of the CDS database view must be specified in quotation marks after the annotation @AbapCatalog.sqlViewName. The usual rules for ABAP Dictionary views apply to this name and it is not case-sensitive (it is transformed internally into uppercase letters). The associated SQL view is created under this name on the database.

  • The name cds_entity of the CDS entity is defined after the keywords DEFINE VIEW (DEFINE is optional). No quotation marks need to be specified. This name follows the rules of the CDS database view, but it can be 30 places in length.

Both names are in the namespace of the data types in ABAP Dictionary and must each be unique. The two names can be used in other DDL statements or in ABAP programs to access the CDS view.


它提到了一些其他差异,例如实体在 SAP 的数据字典工具(SE11、SE16)中不可用,以及从实体中进行选择总是在 strict mode 中运行的事实。但关键是:

In the DDL of the CDS and in ABAP, a CDS view can be addressed as a CDS database view CDS_DB_VIEW and as a CDS entity cds_entity. It is strongly recommended, however, that only the CDS entity is used.


当我在一个简单的查询中运行这两个时,我注意到从实体中进行选择时没有 MANDT 列,但是从 CDS 数据库 View 中进行选择时会出现此列。
那么,开发人员在使用 CDS View 时应该牢记数据库 View 和 CDS 实体之间的真正区别是什么?

最佳答案

您不应再查询 ABAP CDS 数据库 View 并将查询限制为使用 ABAP CDS 实体。尽管在 NetWeaver 7.40 中可以查询数据库 View ,但在更高版本中已弃用。所以不要担心数据库 View :-)
请参阅以下文档:Obsolete Access to CDS Views in Open SQL :

To keep the behavior consistent and to use only the defined properties of a CDS view, only the name of the CDS entity should be used to access a CDS view.

Direct access to a CDS database view is forbidden in strict mode from Release 7.50.


关于客户端处理,您应该相应地关注 CDS 实体的客户端行为。描述了不同的选项 ABAP CDS Client Handling .

关于abap - 从 CDS 实体中选择还是从 CDS 数据库 View 中选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41166557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com