当前位置:网站首页>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 .
边栏推荐
- Correct posture and landing practice of R & D efficiency measurement (speech ppt sharing version)
- 10 suggestions for 10x improvement of application performance
- 2021年CS保研经历(四):西交软院预推免、信工所三室预推免
- 【黑马早报】每日优鲜回应解散,多地已无法下单;李斌称蔚来将每年出一部手机;李嘉诚欲抄底恒大香港总部大楼;今年国庆休7天上7天...
- [ts]typescript learning record pit collection
- node(二)
- Yin Yi: my learning and growth path
- [FPGA tutorial case 18] develop low delay open root calculation through ROM
- Logistic regression of machine learning
- The maximum length of VARCHAR2 type in Oracle is_ Oracle modify field length SQL
猜你喜欢

最新翻译的官方PyTorch简易入门教程(PyTorch1.0版本)

Some suggestions for programmers to leave single

开放原子开源基金会黄金捐赠人优博讯携手合作伙伴,助力OpenHarmony破圈!

MySQL infrastructure: SQL query statement execution process

What kind of framework is friendly to developers?

Why does the system we developed have concurrent bugs? What is the root cause of concurrent bugs?

“为机器立心”:朱松纯团队搭建人与机器人的价值双向对齐系统,解决人机协作领域的重大挑战

Read Plato farm's eplato and the reason for its high premium

i. Mx6ull driver development | 32 - manually write a virtual network card device

关系型数据库之MySQL8——由内而外的深化全面学习
随机推荐
Comprehensively design an oppe home page -- the bottom of the page
Summary of window system operation skills
Div horizontal layout aligned on both sides
Soft exam summary
shell编程之sed,正则表达式
i. Mx6ull driver development | 32 - manually write a virtual network card device
SkiaSharp 之 WPF 自绘 弹动小球(案例版)
Intel joins hands with datawhale to launch learning projects!
开放原子开源基金会黄金捐赠人优博讯携手合作伙伴,助力OpenHarmony破圈!
Sample is new and supported from API 8! Come and take it
div 水平排列
Unity3d empty package APK error summary
Mysql database final review question bank
高效能7个习惯学习笔记
引入redis缓存出现的问题以及解决方式
Problems and solutions of introducing redis cache
7.9-7.17 new features and grammar of learning plan ES6
SiC功率半导体产业高峰论坛成功举办
Functions and arrays
“为机器立心”:朱松纯团队搭建人与机器人的价值双向对齐系统,解决人机协作领域的重大挑战