当前位置:网站首页>SAP Fiori @OData. Analysis of the working principle of publish annotation
SAP Fiori @OData. Analysis of the working principle of publish annotation
2022-07-29 10:04:00 【Wang Zixi】
The author's previous article SAP Fiori annotation @ObjectModel.readOnly Working principle analysis , It introduces SAP Fiori In the programming model @ObjectModel.readOnly How annotations work .SAP Fiori annotation , yes ABAP Programming Model for SAP Fiori It's one of the most important concepts .
So called annotation (annotation),Java and JavaScript Developers must be familiar .
Allied ,CDS Comments allow ABAP Developer , take ABAP And component specific metadata added to any CDS In the source code of the entity .
Implementation details are evaluated based on consistency and annotation validity ,SAP CDS view The annotations of are divided into the following two categories :
ABAP annotation : from ABAP Runtime environmental assessment .
Component annotation : By related SAP The framework is evaluated .
Developers can use annotations in metadata extensions , by CDS The view defines customer specific metadata , Without modification SAP Published standards CDS The entity itself . When using metadata extension , You can override specific annotation values defined in the data definition , Or add additional annotation values to the entity .
Comments can be added in CDS view Up or down view field On , Here is an example :
@AbapCatalog.sqlViewName: 'CUSTOMER'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
DEFINE VIEW cust_book_view_entity
AS SELECT FROM scustom
JOIN sbook
ON scustom.id = sbook.customid
{
@EndUserText.label: 'Customer ID'
scustom.id,
@EndUserText.label: 'Customer Name'
scustom.name,
@EndUserText.label: 'Customer Booking ID'
sbook.bookid
}
This article continues to explore another annotation @OData.publish How it works .
stay SAP Official website ABAP Programming Model for SAP Fiori In the help document of , stay OData Annotations There are comments on this under the directory Introduce .

Once this annotation is added CDS view Activation time , It will automatically generate a OData service .

This OData How services are automatically generated ? This is what this article will share .
SAP Fiori The programming model supports a new OData How services are exposed , such OData Model definition of service , Runtime , be based on Service Adaptation Description Language abbreviation SADL.
Here is an example :
@AbapCatalog.sqlViewName: 'SQL_VIEW_SAMPLE'
...
@OData.publish: true
define view CDS_VIEW_NAME as select from
...
}
Use SAP ABAP Development Tool, open CDS View source code editing page , take OData Comments added to CDS After the view , Can trigger the whole DDL Activation of source .ABAP The development tool delegates the activation request to SADL frame .SADL Generate several SAP Gateway artifacts (Artifacts), These components are stored in the application server AS ABAP Backend , yes SAP Gateway hub Activation and operation in the system OData Necessary for the service .

That's through CDS view expose OData Theoretical knowledge of service .
Suppose we add this annotation to CDS view Automatically generated after activation OData I know nothing about the details of the service , Where to start the research ?
I created a project called zjerrytest20160311 Of view, Then add this annotation , Activate . According to my experience , according to SAP practice , Automatically generated OData The name of the service should also contain 0311 This string .

After activation , I try to use 0311 As a keyword in OData Registration transaction code of the service /IWFND/MAINT_SERVICE Search inside , Sure enough, I found the corresponding generated OData service :

The article before the author ABAP In programming language Class( class ) Analysis of design principle It was mentioned that ABAP Netweaver The registry TADIR, according to 0311 The query , Find out CDS view After activation , except OData Service itself , The following objects are also automatically generated :

- IWMO: SAP Gateway Business Suite Enablement Corresponding model
- IWSV: SAP Gateway Business Suite Enablement Corresponding services
- CLAS: OData The implementation class of the service ZCL_ZJERRYTEST20160311
Do an experiment , When I put OData.publish Is set to false, Activate again , The discovery type is IWMO and IWSV Objects from the registry TADIR It's gone , This once again confirms that the two are annotations OData.publish Set to true Later activation CDS view Generated .

So how to study CDS view Activation time , The automatic generation logic of these two objects ?
Open transaction code ST05, Enter tracking mode , Activate CDS view, In the database tracking results, it was found that the automatically generated object name was inserted into the registry TADIR Of OPEN SQL sentence .

stay ABAP in , Insert database table in OPEN SQL The statement before , The generation logic of the data must be inserted .
Click on ST05 Blue glasses icon in , Auto jump to OPEN SQL In the sentence . To set breakpoints , Activate CDS view, Breakpoints trigger :

Trace back from the current call stack , It was found in the 21 Call stack frames , It is automatically generated OData The place to serve :

CL_WB_DDLS_SECOBJ_HNDLR_SINGLE->IF_DDIC_WB_DDLS_SECOBJ_HANDLER~ON_ACTIVATION
This method is first based on delta_state Determine that it needs to be deleted , List of new or updated objects , Respectively stored in the following figure 12 To 14 Among the three output parameters .

for instance , When I am in an activated CDS view Add @OData.publish:true Annotations , Then activate , At this time, the annotation is for EDIT_STATE by N(New), And the other annotations have no change , Marked as U(Unchanged).

Here will be based on EDIT_STATE Value , Enter the corresponding branch .

EDIT_STATE The value is N The branch of , execute OData Service creation , adopt CL_SADL_GTK_ODATA_SERVICE_GEN complete , suffix GEN representative Generation.

You can see from the debugger , The name is ZJERRYTEST20160311 Of OData Service pass create_via_exposure Method is created .
Complete call stack :

This article is actually another specific example , Without understanding a piece of logic ( Whether at the framework level or the application level ) Under the circumstances , How to use ST05 This tool is used to find the location of the code that sets the breakpoint , So as to find a breakthrough in problem analysis .
summary
From the perspective of a developer , In depth SAP Fiori annotation @OData.publish How it works . It also shows how to pass the thing code ST05, Self positioning to ABAP The framework automatically generates OData The exact code location of the service resource .
边栏推荐
- 待人宽容大度
- System architect learning
- 10 suggestions for 10x improvement of application performance
- Youboxun, the gold donor of the open atom open source foundation, joined hands with partners to help openharmony break the circle!
- Anfulai embedded weekly report no. 273: 2022.07.04--2022.07.10
- 还是有机会的
- [ts]Typescript学习记录坑点合集
- 关系型数据库之MySQL8——由内而外的深化全面学习
- Is it safe to open an account online now? Do you want to know that you must go to the business hall to open an account now?
- 什么是卡特兰数?有哪些应用?
猜你喜欢

ORBSLAM2安装测试,及各种问题汇总

通俗易懂讲解梯度下降法!

How to customize the opportunity closing form in dynamics 365online

Where are those test / development programmers in their 30s? a man should be independent at the age of thirty......

【微信小程序】接口生成自定义首页二维码

QoS服务质量五QoS边界行为之流量整形

What kind of framework is friendly to developers?

Source code analysis of senparc.weixin.sample.mp

Unity3d空包打apk报错汇总

On memory computing integrated chip technology
随机推荐
Source code analysis of senparc.weixin.sample.mp
Only simple function test? One article takes you to advanced interface automatic testing technology in 6 steps
Linear regression of machine learning (least square handwriting +sklearn Implementation)
Talk about multithreaded concurrent programming from a different perspective without heap concept
This is an incomplete data competition Yearbook!
How to customize the opportunity closing form in dynamics 365online
Tips of Day1 practice in 2022cuda summer training camp
Some suggestions for programmers to leave single
Are you familiar with the redis cluster principle of high paid programmers & interview questions series 122? How to ensure the high availability of redis (Part 2): cluster mechanism and principle, clu
MySQL优化理论学习指南
跟着李老师学线代——矩阵(持续更新)
[AAAI] attention based spatiotemporal graph convolution network for traffic flow prediction
mysql 数据库 期末复习题库
i. Mx6ull driver development | 32 - manually write a virtual network card device
[FPGA tutorial case 18] develop low delay open root calculation through ROM
尹伊:我的学习成长路径
Logistic regression of machine learning
全面、详细的SQL学习指南(MySQL方向)
一文读懂Plato Farm的ePLATO,以及其高溢价缘由
Summary of window system operation skills