- 自定义 CDS Views 基本步骤
- Step 1. 基本信息
- Step 2. Publish
- Step 3. Create Custom Communication Scenario
- Step 4. Create Communication Arrangement
- Business Role ID: SAP_BR_ADMINISTRATOR
- Business Catalog ID: SAP_CORE_BC_EXT
在 Applications for General Functions for Key Users 页面可以查到所有 S/4HANA Cloud 通用功能的应用程序，可以看到其 Business Role ID 和 Business Catalog ID。
自定义 CDS Views 基本步骤
- Field Selection
- Field Properties
Step 1. 基本信息
打开 Extensibility -> Custom CDS Views App
- 在 S/4HANA Cloud 中自定义 CDS Views 名称是以 ‘YY1’ 开头, 在 S/4HANA (OP) 中则是以 ‘ZZ1’ 开头. 这里我们的是 YY1_A_SalesOrderItemCube
- External API checkbox: Enable OData API for External Consumption via Communication Scenario and Communication Arrangement
- For Analytical scenario: Dimension and Cube
添加主 Data Source View
我们在 Data Source 里添加 Primary Data Source 为 Interface View：I_SalesOrderItemCube
添加关联的 Data Source View
在关联的 Data Source Views 里添加这个视图: Interface View: I_SalesDocumentItem (Use table VBAK, VBAP, VBKD, VEDA as sources)
Do you really want to add an access-protected data source?
When associating an access-protected data source to a custom CDS view, the access protection of the associated data source will not be considered for the access protection of the custom CDS view. For further information, see SAP Note 2540696.
Step 2. Publish
然后 Publish: OData service YY1_A_SALESORDERITEMCUBE_CDS was generated. OData Name 就是在 CDS View Name 后加后缀 _CDS
产生的 OData 服务就可以用在 FIORI App 里调用，或者用在 Communication Scenario 里供外部系统调用。
- 什么是 drill down?
- C_* Consumption View: The view consumed by application (Tech name: C_*). e.g. Journal Entry Analyzer (C_GLLINEITEMSQ0001). It is created from Interface View in general.
- I_* interface view: The view as the foundation (Tech name: I_*).. The view as the general foundation for Consumption view. Interface View for business entities in S/4HANA is called Basic View, e.g. GL Account Line Item (I_GLAccountLineItem), Profit Center (I_ProfitCenter). Interface view created from Basic View is called Composite View, e.g. G/L Account Balance Cube (I_GLAcctBalanceCube).
- P_* Private View: The view used as a part to create Interface View or Consumption View (Tech name: P_*). It is not mandatory to create.
- E_* Extend View: Extend View is used to add fields to predefined VDM without changing predefined VDM itself. It is possible to associate the view and add it in the source view, and it is also possible to use the association for foreign key association on the added field. It is like APPEND for table in ABAP Dictionary.
In BW context, Consumption View is like BW Query and Interface View is like InfoProvider or InfoObject.
Step 3. Create Custom Communication Scenario
要使开发的 OData 等 API 被外部访问则需要把 API 包裹在 Communication Scenario 里对外发布出去，详细介绍参考 S/4HANA Cloud - Communications in S/4HANA Cloud with other Systems
- Open the Extensibility -> Custom Communication Scenario App
- Click on New, input the ID and Description fields
- Add the Inbound Services, select your custom CDS OData API
- Inbound Services – means when a resource or a design-time artifact from S/4HANA Cloud system is accessed from the external system or environment. For example, you have created a custom CDS view that fetches certain data and you would like to show it externally in some application
- Outbound Services – In simple words, say there is an external service provider and you would like to call that service from within the Custom Logic App or within the Custom Business Object. You can also use Outbound Services to update the data outside of your SAP S/4HANA Cloud System. Consider for example, within the S/4HANA Cloud system in your Custom Business Object you would like to get the updated currency conversion value and then update it in the field in CBO. In such cases, you can create an Outbound Service. To learn more about how to create and use an Outbound Service, please visit this link here
- Communication Arrangements – lists all the communication arrangements created for the custom communication scenario
- In the next step click on Publish button to publish the service for this Custom Communication Scenario
Step 4. Create Communication Arrangement
打开应用 Communication Management -> Communication Arrangements 点击 New 或者从上一步中点击 Create Arrangement
关于 Communication Systems 和 User Name 这里不再赘述，可以参考另一篇 S/4HANA Cloud - Communications in S/4HANA Cloud with other Systems
保存后便可以使用界面中的 Service URL / Service Interface 的链接访问此 OData API 了。