Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How OData services are automatically generated

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how OData services are generated automatically". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how OData services are generated automatically.

Assuming that we have no idea about the details of the automatically generated OData service activated by the CDS view with this annotation, where do we start the research?

I created a view called zjerrytest20160311, and then added this annotation to activate it. In my experience, according to SAP conventions, the name of the automatically generated OData service should also contain the string 0311.

After activation, I tried to search the registration transaction code / IWFND/MAINT_SERVICE of the OData service with 0311 as the keyword, and sure enough, I found the corresponding generated OData service:

In the previous Jerry article [ABAP CCDEF, CCIMP, CCMAC, CCAU, CMXXX] (ABAP CCDEF, CCIMP, CCMAC, CCAU, CMXXX) mentioned ABAP Netweaver registry TADIR, according to 0311 query, found that after CDS view activation, in addition to OData service itself, but also automatically generated the following objects:

IWMO: the model corresponding to SAP Gateway Business Suite Enablement

IWSV: the service corresponding to SAP Gateway Business Suite Enablement

CLAS: the implementation class ZCL_ZJERRYTEST20160311 of OData service

In an experiment, when I set the value of OData.publish to false and activate it again, I found that the objects of type IWMO and IWSV disappeared from the registry TADIR, which once again confirmed that they were generated by activating CDS view after the annotation OData.publish was set to true.

So how do you study the automatic generation logic of these two objects when CDS view is activated?

Use the sixth weapon introduced in the Jerry article (seven weapons of SAP error message debugging: so that all error messages can be located), the ST05 of the parting hook.

Open the ST05 trace mode, activate CDS view, and sure enough, the OPEN SQL statement that inserts the automatically generated object name into the registry TADIR is found in the database trace result.

When the Tianzhu monk went to the valley of despair to find an antidote to the poison of love flowers to Yang Guo, he said: where poisonous snakes are infested, there must be an antidote within seven steps.

Similarly, in ABAP, the data generation logic must be inserted before inserting the OPEN SQL statement of the database table.

Click the blue glasses icon in ST05 and automatically jump to the OPEN SQL statement. Set breakpoint, activate CDS view, and trigger breakpoint:

Tracing back from the current call stack, it is found that the 21st call stack frame is where the OData service is automatically generated:

CL_WB_DDLS_SECOBJ_HNDLR_SINGLE- > IF_DDIC_WB_DDLS_SECOBJ_HANDLER~ON_ACTIVATION

This method first determines the list of objects that need to be deleted, added, or updated according to delta_state, which are stored in the three output parameters in lines 12 to 14, respectively.

For example, when I add the @ OData.publish:true annotation to an activated CDS view source code and then activate it, the comment is N (New) for the EDIT_STATE, while the other annotations are marked U (Unchanged) because there is no change.

Here, according to the value of EDIT_STATE, enter the corresponding branch.

For the branch with an EDIT_ state value of N, the creation of the OData service is performed through CL_SADL_GTK_ODATA_SERVICE_GEN, and the suffix GEN stands for Generation.

As you can see from the debugger, an OData service named ZJERRYTEST20160311 is created through the create_via_exposure method.

Complete call stack:

At this point, I believe you have a deeper understanding of "how OData services are generated automatically". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report