So far we have a working CDS view ready for us to create a UI5 application on top of it via Smart Template in WebIDE within just a couple of minutes. Once done, the UI5 application will display the data from our CDS view like below. For step by step how to achieve this, please refer to this blog: Step by Step to create CDS view through SmartTemplate + WebIDE.
How is navigation implemented among CDS views
In this part, let’s create CDS view which supports node navigation in OData service. The previous CDS view we created has a flat structure which only have a root node. Now let’s create a series of CDS views:
(1) A CDS view which contains two fields: spfli.connid and spfli.carrid. This view acts as the root node of the corresponding OData service model from semantic point of view. This view can support navigation from itself to the defined children node.
(2) A CDS view which acts as the navigation target from previously defined “root” view. Besides the two fields from sflight.connid and sflight.carrid which correspond to the root view, it has additional new field sflight.fldate. OData navigation means suppose currently I am in the context of spfli.connid = 0001 and spfli.carrid ( data record with yellow ), and through navigation I can get all its dependent data in red color. We will see how this navigation would be performed later.
(3) A CDS view which exposes the two fields connid and carrid from root view and the associated data from child view. This view is called “consumption” view and used to published as OData service. Source code of view #1:
@AbapCatalog.sqlViewName: 'zspfliroot'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'root view'
define view Zspfli_Root as select from spfli
association [0..*] to Zsflight_Child as _Item on $projection.carrid = _Item.carrid
and $projection.connid = _Item.connid
{
key spfli.connid,
key spfli.carrid,
@ObjectModel.association.type: #TO_COMPOSITION_CHILD
_Item
}
Source code of view #2:
@AbapCatalog.sqlViewName: 'zsflightchild'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'child_view'
define view Zsflight_Child as select from sflight
association [1..1] to zspfli_root as _root
on $projection.connid = _root.connid
and $projection.carrid = _root.carrid
{
key sflight.carrid,
key sflight.connid,
key sflight.fldate,
@ObjectModel.association.type: [#TO_COMPOSITION_ROOT, #TO_COMPOSITION_PARENT]
_root
}
Source code of view #3:
@AbapCatalog.sqlViewName: 'zflight_c'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'flight consumption view'
@OData.publish: true
@ObjectModel: {
type: #CONSUMPTION,
compositionRoot,
createEnabled,
deleteEnabled,
updateEnabled
}
define view Zflight_Com as select from Zspfli_Root {
key Zspfli_Root.carrid,
key Zspfli_Root.connid,
@ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
Zspfli_Root._Item
}
Activate all of these three CDS views. Since the third consumption view has annotation @OData.publish: true, once activated there will be an OData service automatically generated:
How to test navigation
First check the response from OData metadata request via url/sap/opu/odata/sap/ZFLIGHT_COM_CDS/$metadata in gateway client. You should find two AssociationSets generated based on corresponding annotation in CDS views.
The entityset Zflight_Com has type Zflight_ComType, which has the navigation Property “to_Item”. Now we can test the navigation.
First we get the root node’s content via url:/sap/opu/odata/sap/ZFLIGHT_COM_CDS/Zflight_Com(connid=’0400′,carrid=’LH’) .
And in the response, we are told that the correct url for navigation from current node to its child node is just to append the navigation property defined in metadata, toItem, to the end of url, that is,/sap/opu/odata/sap/ZFLIGHT_COM_CDS/Zflight_Com(connid=’0400′,carrid=’LH’)/to_Item .
How the navigation is implemented in ABAP side
Set the breakpoint in the method below and re-trigger the navigation operation. Check the generated SQL statement in variable statement in line 27.
SELECT "Zsflight_Child"."CARRID" AS "CARRID", "Zsflight_Child"."CONNID" AS "CONNID", "Zsflight_Child"."FLDATE" AS "FLDATE" FROM "ZSFLIGHTCHILD" AS "Zsflight_Child"
WHERE "Zsflight_Child"."CARRID" = ? AND "Zsflight_Child"."CONNID" = ? AND "Zsflight_Child"."MANDT" = '001' WITH PARAMETERS( 'LOCALE' = 'CASE_INSENSITIVE' )
The value for two placeholders ( ? ) are stored in me->parameters->param_tab:
And check response in et_flag_data:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关推荐
在深入探讨SAP UI5 OData开发之前,需要明确几个关键点:SAP UI5是一个前端开发框架,而OData(Open Data Protocol)是一种基于Web的协议,允许创建和消费可查询和可更新的数据服务。SAP Gateway是SAP NetWeaver的一...
在SAP系统中,ODATA(Open Data Protocol)是一种基于RESTful架构的Web服务协议,它使得客户端可以简便地访问和操作服务器上的数据。...学习完这个教程,你将具备在SAP环境中构建高效、安全的ODATA服务的能力。
本文将详细介绍SAP后台ODATA开发的步骤,供初学者参考。 **一、数据结构** 在SAP ODATA开发中,首先需要定义数据结构,这是服务的基础。这里有两个关键的数据结构:ZORDER_HEADER和ZORDER_ITEM。 - **ZORDER_...
SAP ODATA Training Agenda • Session 1: Introduction to SAPUI5 / FIORI (40 mins) ▫ Basic MVC concept: Model, View, Controller ▫ UI5 Control libraries • Session 2: Introduction to SAP Web IDE (20 ...
SAP OData Training Agenda • Session 1: Introduction to REST (20 mins) • Session 2: Introduction to OData Service (40 mins) • Hands on 1: Build your 1 st OData Service (60 mins) ▫ Transaction: SEGW...
### JAVA调用SAP ODATA服务的关键知识点 在IT领域,特别是企业级应用开发中,Java与SAP系统的集成是一项非常重要的技术。SAP提供了多种API和服务来促进与其他系统的交互,其中ODATA(Open Data Protocol)是一种轻...
在Java开发中,调用SAP ODATA服务是企业级集成和数据交换的常见场景。在实际操作中,可能会遇到一些挑战,如身份验证、请求方法的使用、跨域问题以及错误处理。以下是对这些知识点的详细说明: 1. **身份验证 (401 ...
SapAPI 该程序正在读取SAP API。 此API从防火墙后面的SAP ECC系统公开ODATA。 需要一个天蓝色的AD帐户,一个SAP-id,包括访问SAP系统中技术角色的权限。 SAP API已在Azure API管理中注册。
通过遵循OData的最佳实践,开发人员可以在构建高度可用的RESTful API时获得更好的体验和支持。此外,了解OData服务的生命周期对于确保长期稳定运行至关重要。最终目标是构建出既符合业务需求又易于维护和扩展的应用...
SAP Process Orchestration The Comprehensive Guide, 2nd Edition SAP流程编制综合指南 1 Introduction to SAP Process Orchestration 1.1 Historical Overview and Evolution 1.1.1 SAP Process Integration ...
【SAP Gateway与OData】是SAP低代码开发中的关键组成部分,对于理解和实现企业级应用集成至关重要。SAP Gateway是一种技术平台,它允许不同系统之间的数据交换,特别是与SAP系统和其他非SAP系统之间的交互。OData...
在学习和开发 SAP UI5 应用时,可以通过一系列的教程,如 SAP UI5 Walkthrough,来掌握基本的开发流程、数据绑定、导航、控件扩展和响应式设计等概念,以及最佳的开发实践和测试技巧。 总的来说,SAP UI5 是一个...
3. **SAP HANA Cloud Platform**:介绍SAP云平台的角色,它是如何与SAP Gateway和OData结合,提供云端开发和部署环境的。 4. **ABAP编程**:作为SAP系统的主要开发语言,ABAP在创建和维护OData服务中的作用,以及...
在本教程中,我们将深入探讨如何开发一个使用SAPUI5和oData访问的数据交互应用程序。SAPUI5是SAP提供的一个强大的JavaScript框架,用于构建企业级的Web应用程序。而oData是一种开放的协议,它允许客户端通过HTTP访问...
本课程将由浅入深,从后端到前端,从较早的Eclipse开发到现在流行的WebIDE开发,从SAPUI5到ABAP 再到CDS, 从简单的List APP到较为复杂的Fiori Element开发,系统性地讲述SAP Fiori的开发过程。学员学习本套课程后,...
OData库 一个NodeJS库,用于访问Netweaver服务器提供的OData服务。 安装 $ npm install @sap_oss/odata-library 入门 const Service = require ( "@sap_oss/odata-library" ) . Service ; let service = new Service...
另请查看以下博客文章,了解如何在本地开发环境和 SAP 业务技术平台 (BTP)、Cloud Foundry 上开始使用cds-pg : 去做 实现基本的SELECT|READ (~ OData GET ) 实现基本的INSERT|CREATE (~ OData POST ) 实现基本...
通过学习和实践这个“SAPUI5-OData-V4”项目,你不仅可以深化对SAPUI5的理解,还能掌握如何高效地利用OData V4模型进行数据操作,这对于任何希望在企业级Web开发中使用SAPUI5的开发者来说都是一份宝贵的资源。
OData:开放数据协议(Open Data Protocol,简称OData)是一种描述如何创建和访问Restful服务的OASIS标准。该标准由微软发起,前三个版本1.0、2.0、3.0都是微软开放标准,遵循微软开放规范承诺书(Microsoft Open ...
SAP Gateway是一个技术平台,它为开发人员提供了创建和提供基于OData(Open Data Protocol)的服务的工具。这些服务使得非SAP系统能够通过标准接口,如REST(Representational State Transfer)访问SAP数据。这大大...